Accepting request 540339 from home:markkp:branches:Base:System
- Updated the cputype script to recognize the new IBM z14 processor (bsc#1049843). - Re-instated the new versions of ctc_configure, dasd_configure, qeth_configure, zfcp_disk_configure, zfcp_host_configure. OBS-URL: https://build.opensuse.org/request/show/540339 OBS-URL: https://build.opensuse.org/package/show/Base:System/s390-tools?expand=0&rev=29
This commit is contained in:
parent
d718dd8e55
commit
4c67ea0039
3
cputype
3
cputype
@ -2,7 +2,7 @@
|
||||
#
|
||||
# cputype
|
||||
#
|
||||
# Copyright (c) 2014-2016 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2014-2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# Based on the IBM machine model, returns a (hopefully) human understandable
|
||||
# string that identifies the processor.
|
||||
@ -58,6 +58,7 @@ case "${machine}" in
|
||||
2828) echo "${machine} = z12-BC IBM zEnterprise BC12" ;;
|
||||
2964) echo "${machine} = z13 IBM z13" ;;
|
||||
2965) echo "${machine} = z13s IBM z13s (single frame)" ;;
|
||||
3906) echo "${machine} = z14 IBM z14" ;;
|
||||
*) echo "An unknown machine type was reported: ${machine}" >&2
|
||||
echo "Please file a bug report with this output:" >&2
|
||||
/bin/cat /proc/cpuinfo >&2
|
||||
|
363
ctc_configure
363
ctc_configure
@ -2,316 +2,127 @@
|
||||
#
|
||||
# ctc_configure
|
||||
#
|
||||
# Configures a CTC device
|
||||
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# Configures a CTC device by calling the IBM-provided chzdev command.
|
||||
# Whereas this script used to validate the parameters provided to it,
|
||||
# we now rely on chzdev to do that instead. The script is intended only
|
||||
# as a "translation layer" to provide backward compatability for older
|
||||
# scripts and tools that invoke it.
|
||||
#
|
||||
# Usage:
|
||||
# ctc_configure <read channel> <write channel> <online> [<protocol>]
|
||||
#
|
||||
# read/write channel = 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.
|
||||
# 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
|
||||
# protocol = 0 Compatibility with peers other than OS/390®, or z/OS, for example, a z/VM TCP service machine. This is the default.
|
||||
# protocol = 0 Compatibility with peers other than OS/390®, or z/OS, for
|
||||
# example, a z/VM TCP service machine. This is the default.
|
||||
# 1 Enhanced package checking for Linux peers.
|
||||
# 3 For compatibility with OS/390 or z/OS peers.
|
||||
# 4 For MPC connections to VTAM on traditional mainframe operating systems.
|
||||
# 4 For MPC connections to VTAM on traditional mainframe
|
||||
# operating systems.
|
||||
#
|
||||
# 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 Invalid device type
|
||||
# 6 Device type mismatch
|
||||
# 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
|
||||
# Return codes are determined by the chzdev command.
|
||||
#
|
||||
|
||||
if [ "${DEBUG}" != "yes" ]; then
|
||||
DEBUG="no"
|
||||
fi
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
mesg () {
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
debug_mesg () {
|
||||
case "$DEBUG" in
|
||||
yes) mesg "$@" ;;
|
||||
*) ;;
|
||||
case "${DEBUG}" in
|
||||
yes) mesg "$@" ;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Get the mount point for sysfs
|
||||
while read MNTPT MNTDIR MNTSYS MNTTYPE; do
|
||||
if test "$MNTSYS" = "sysfs"; then
|
||||
SYSFS="$MNTDIR"
|
||||
break;
|
||||
fi
|
||||
done </proc/mounts
|
||||
add_cio_channel() {
|
||||
echo "$* # ${DATE}" >> /boot/zipl/active_devices.txt
|
||||
}
|
||||
|
||||
if [ -z "$SYSFS" ]; then
|
||||
mesg "/sysfs not present"
|
||||
exit 1
|
||||
remove_cio_channel() {
|
||||
[ -w /boot/zipl/active_devices.txt ] && sed -i -e "/^${1}/d" /boot/zipl/active_devices.txt
|
||||
}
|
||||
|
||||
usage(){
|
||||
echo "Usage: ${0} <read channel> <write channel> <online> [<protocol>]"
|
||||
echo " read/write channel = x.y.ssss where"
|
||||
echo " x is always 0 until IBM creates something that"
|
||||
echo " uses that number"
|
||||
echo " y is the logical channel subsystem (lcss) number."
|
||||
echo " Most often this is 0, but it could be non-zero"
|
||||
echo " ssss is the four digit subchannel address of the"
|
||||
echo " device, in hexidecimal, with leading zeros."
|
||||
echo " online = 0 to take the device offline"
|
||||
echo " 1 to bring the device online"
|
||||
echo " protocol = 0 Compatibility with peers other than OS/390®, or z/OS, for"
|
||||
echo " example, a z/VM TCP service machine. This is the default."
|
||||
echo " 1 Enhanced package checking for Linux peers."
|
||||
echo " 3 For compatibility with OS/390 or z/OS peers."
|
||||
echo " 4 For MPC connections to VTAM on traditional mainframe"
|
||||
echo " operating systems."
|
||||
}
|
||||
|
||||
if [ "${DEBUG}" != "yes" ]; then
|
||||
DEBUG="no"
|
||||
fi
|
||||
|
||||
if [ $# -lt 3 ] ; then
|
||||
echo "Usage: $0 <read channel> <write channel> <online> [<protocol>]"
|
||||
echo " read/write channel = 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"
|
||||
echo " protocol = 0 Compatibility with peers other than OS/390®, or z/OS, for example, a z/VM TCP service machine. This is the default."
|
||||
echo " 1 Enhanced package checking for Linux peers."
|
||||
echo " 3 For compatibility with OS/390 or z/OS peers."
|
||||
echo " 4 For MPC connections to VTAM on traditional mainframe operating systems."
|
||||
exit 1
|
||||
DATE=$(date)
|
||||
|
||||
CTC_READ_CHAN=${1}
|
||||
CTC_WRITE_CHAN=${2}
|
||||
ON_OFF=${3}
|
||||
CTC_MODE=${4}
|
||||
|
||||
if [ -z "${CTC_READ_CHAN}" ] || [ -z "${CTC_WRITE_CHAN}" ] || [ -z "${ON_OFF}" ]; then
|
||||
mesg "You didn't specify all the needed parameters."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CTC_READ_CHAN=$1
|
||||
CTC_WRITE_CHAN=$2
|
||||
ONLINE=$3
|
||||
CTC_MODE=$4
|
||||
|
||||
[ -z "$CTC_MODE" ] && CTC_MODE=0
|
||||
|
||||
if [ -z "$ONLINE" ] || [ "$ONLINE" -ne "1" -a "$ONLINE" -ne "0" ]; then
|
||||
mesg "Invalid device status $ONLINE"
|
||||
exit 2
|
||||
if [ -z "${CTC_MODE}" ]; then
|
||||
PARM_LIST="${PARM_LIST} protocol=0"
|
||||
else PARM_LIST="${PARM_LIST} protocol=${CTC_MODE}"
|
||||
fi
|
||||
|
||||
_ccw_dir=${SYSFS}/bus/ccw/devices
|
||||
|
||||
debug_mesg "Configuring CTC/LCS device ${CTC_READ_CHAN}/${CTC_WRITE_CHAN}"
|
||||
|
||||
|
||||
if test ! -d "$_ccw_dir/$CTC_READ_CHAN" ; then
|
||||
mesg "device $_ccw_dir/$CTC_READ_CHAN does not exist"
|
||||
exit 3
|
||||
fi
|
||||
if test ! -d "$_ccw_dir/$CTC_WRITE_CHAN" ; then
|
||||
mesg "device $_ccw_dir/$CTC_WRITE_CHAN does not exist"
|
||||
exit 4
|
||||
if [ -f /sys/bus/ccw/devices/${CTC_READ_CHAN}/cutype ]; then
|
||||
read CU_TYPE < /sys/bus/ccw/devices/${CTC_READ_CHAN}/cutype
|
||||
else mesg "Psuedo file/sys/bus/ccw/devices/${CTC_READ_CHAN}/cutype doesn't exist."
|
||||
mesg "Check to see if sysfs is mounted."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CCW_CHAN_GROUP=
|
||||
for ccw in $_ccw_dir/$CTC_READ_CHAN $_ccw_dir/$CTC_WRITE_CHAN; do
|
||||
|
||||
read _cu_type < $ccw/cutype
|
||||
read _dev_type < $ccw/devtype
|
||||
|
||||
case "$_cu_type" in
|
||||
3088/01)
|
||||
# P/390 network adapter
|
||||
CCW_CHAN_NAME="cu3088"
|
||||
CCW_CHAN_GROUP="lcs"
|
||||
;;
|
||||
3088/08)
|
||||
# Channel To Channel
|
||||
CCW_CHAN_NAME="cu3088"
|
||||
CCW_CHAN_GROUP="ctcm"
|
||||
;;
|
||||
3088/1e)
|
||||
# FICON adapter
|
||||
CCW_CHAN_NAME="cu3088"
|
||||
CCW_CHAN_GROUP="ctcm"
|
||||
;;
|
||||
3088/1f)
|
||||
# ESCON adapter (I.e. hardware CTC device)
|
||||
CCW_CHAN_NAME="cu3088"
|
||||
CCW_CHAN_GROUP="ctcm"
|
||||
;;
|
||||
3088/60)
|
||||
# Lan Channel Station
|
||||
CCW_CHAN_NAME="cu3088"
|
||||
CCW_CHAN_GROUP="lcs"
|
||||
;;
|
||||
*)
|
||||
CCW_CHAN_NAME=
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$CCW_CHAN_NAME" ]; then
|
||||
mesg "Not a valid CTC device (cu $_cutype, dev $_devtype)"
|
||||
exit 5
|
||||
fi
|
||||
|
||||
[ -z "$tmp_chan" ] && tmp_chan=$CCW_CHAN_GROUP
|
||||
done
|
||||
|
||||
if [ "$tmp_chan" != "$CCW_CHAN_GROUP" ] ; then
|
||||
mesg "CTC type mismatch (read: $tmp_chan, write: $CCW_CHAN_GROUP)"
|
||||
exit 6
|
||||
if [ "${CU_TYPE}" == "3088/01" ] || [ "${CU_TYPE}" == "3088/60" ]; then
|
||||
DEV_TYPE="lcs"
|
||||
else DEV_TYPE="ctc"
|
||||
fi
|
||||
|
||||
_ccw_groupdir=${SYSFS}/bus/ccwgroup
|
||||
|
||||
# Check for modules
|
||||
if test ! -d "${_ccw_groupdir}/drivers/${CCW_CHAN_GROUP}" ; then
|
||||
/sbin/modprobe $CCW_CHAN_GROUP
|
||||
|
||||
# Re-check whether module loading has succeeded
|
||||
if test ! -d "${_ccw_groupdir}/drivers/${CCW_CHAN_GROUP}"; then
|
||||
mesg "Could not load module ${CCW_CHAN_GROUP}"
|
||||
exit 7
|
||||
fi
|
||||
if [ "${ON_OFF}" == 0 ]; then
|
||||
debug_mesg "chzdev -d ${DEV_TYPE} ${CTC_READ_CHAN}"
|
||||
chzdev -d ${DEV_TYPE} ${CTC_READ_CHAN}
|
||||
elif [ "${ON_OFF}" == 1 ]; then
|
||||
debug_mesg "chzdev -e ${DEV_TYPE} ${CTC_READ_CHAN} ${PARM_LIST}"
|
||||
chzdev -e ${DEV_TYPE} ${CTC_READ_CHAN} ${PARM_LIST}
|
||||
else mesg "You must specify a 0 or a 1 for the online/offline attribute."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for grouping
|
||||
_ccw_status_dir=
|
||||
if [ -e ${_ccw_dir}/${CTC_READ_CHAN}/group_device ] ; then
|
||||
_ccw_status_dir=$(cd -P ${_ccw_dir}/${CTC_READ_CHAN}/group_device; echo $PWD)
|
||||
fi
|
||||
if [ -e ${_ccw_dir}/${CTC_WRITE_CHAN}/group_device ] ; then
|
||||
_tmp_status_dir=$(cd -P ${_ccw_dir}/${CTC_READ_CHAN}/group_device; echo $PWD)
|
||||
if [ "$_ccw_status_dir" ] && [ "$_ccw_status_dir" != "$_tmp_status_dir" ] ; then
|
||||
mesg "CCW devices grouped to different devices"
|
||||
exit 8
|
||||
fi
|
||||
_ccw_status_dir=$_tmp_status_dir
|
||||
fi
|
||||
#
|
||||
# Addresses are free (but may be bound to the wrong driver)
|
||||
#
|
||||
_ccw_drivers=${SYSFS}/bus/ccw/drivers
|
||||
for i in ${CTC_READ_CHAN} ${CTC_WRITE_CHAN}
|
||||
do
|
||||
if [ "$CCW_CHAN_GROUP" = "lcs" ]
|
||||
then
|
||||
if [ -e "${_ccw_drivers}/ctcm/${i}" ] ; then
|
||||
echo $i > ${_ccw_drivers}/ctcm/unbind
|
||||
fi
|
||||
if [ ! -e "${_ccw_drivers}/lcs/${i}" ] ; then
|
||||
echo $i > ${_ccw_drivers}/ctcm/bind
|
||||
fi
|
||||
else
|
||||
if [ -e "${_ccw_drivers}/lcs/${i}" ] ; then
|
||||
echo $i > ${_ccw_drivers}/lcs/unbind
|
||||
fi
|
||||
if [ ! -e "${_ccw_drivers}/ctcm/${i}" ] ; then
|
||||
echo $i > ${_ccw_drivers}/ctcm/bind
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
debug_mesg "Group is ${_ccw_groupdir}/drivers/${CCW_CHAN_GROUP}/group"
|
||||
if [ -z "$_ccw_status_dir" ] ; then
|
||||
echo "$CTC_READ_CHAN,$CTC_WRITE_CHAN" > ${_ccw_groupdir}/drivers/${CCW_CHAN_GROUP}/group
|
||||
if [ -e ${_ccw_dir}/${CTC_READ_CHAN}/group_device ] ; then
|
||||
_ccw_status_dir=$(cd -P ${_ccw_dir}/${CTC_READ_CHAN}/group_device; echo $PWD)
|
||||
fi
|
||||
RC=${?}
|
||||
if [ ${RC} -ne 0 ]; then
|
||||
exit ${RC}
|
||||
fi
|
||||
|
||||
if [ -z "$_ccw_status_dir" -o ! -e "$_ccw_status_dir" ] ; then
|
||||
mesg "Could not group $CCW_CHAN_GROUP devices $CTC_READ_CHAN/$CTC_WRITE_CHAN"
|
||||
exit 9
|
||||
fi
|
||||
|
||||
CCW_CHAN_ID=${_ccw_status_dir##*/}
|
||||
|
||||
read _ccw_dev_status < $_ccw_status_dir/online
|
||||
|
||||
if [ "$ONLINE" -eq 1 ]; then
|
||||
# Check whether we need to do something
|
||||
if [ "$_ccw_dev_status" -eq 0 ]; then
|
||||
if [ "$CTC_MODE" -gt 0 -a "$CCW_CHAN_GROUP" != "lcs" ]; then
|
||||
echo $CTC_MODE > $_ccw_status_dir/protocol
|
||||
fi
|
||||
# Set the device online
|
||||
debug_mesg "Setting device online"
|
||||
echo "1" > $_ccw_status_dir/online
|
||||
# Re-read device status
|
||||
read _ccw_dev_status < $_ccw_status_dir/online
|
||||
if [ "$_ccw_dev_status" -eq 0 ]; then
|
||||
mesg "Could not set device ${CCW_CHAN_ID} online"
|
||||
exit 10
|
||||
fi
|
||||
else
|
||||
debug_mesg "Device ${CCW_CHAN_ID} is already online"
|
||||
fi
|
||||
else
|
||||
if [ "$_ccw_dev_status" -eq 1 ]; then
|
||||
# Set the device offline
|
||||
debug_mesg "Setting device offline"
|
||||
echo "$ONLINE" > $_ccw_status_dir/online
|
||||
|
||||
# Re-read to check whether we have succeeded
|
||||
_ccw_dev_status=$(cat $_ccw_status_dir/online)
|
||||
if [ "$_ccw_dev_status" -ne "$ONLINE" ]; then
|
||||
mesg "Could not set device ${CCW_CHAN_ID} offline"
|
||||
exit 11
|
||||
fi
|
||||
else
|
||||
debug_mesg "Device ${CCW_CHAN_ID} is already offline"
|
||||
fi
|
||||
# Always reset CTC Protocol
|
||||
if [ "$CCW_CHAN_GROUP" != "lcs" ]; then
|
||||
echo 0 > $_ccw_status_dir/protocol
|
||||
fi
|
||||
fi
|
||||
|
||||
RULES_DIR=/etc/udev/rules.d
|
||||
RULES_FILE=51-${CCW_CHAN_GROUP}-${CCW_CHAN_ID}.rules
|
||||
|
||||
if [ -d "$RULES_DIR" ]; then
|
||||
if [ -f ${RULES_DIR}/${RULES_FILE} ]; then
|
||||
rm -f ${RULES_DIR}/${RULES_FILE}
|
||||
fi
|
||||
remove_channel_for_cio "$CTC_READ_CHAN"
|
||||
remove_channel_for_cio "$CTC_WRITE_CHAN"
|
||||
|
||||
if [ "$ONLINE" -eq "1" ]; then
|
||||
add_channel_for_cio "$CTC_READ_CHAN,$CTC_WRITE_CHAN"
|
||||
# Write a new udev rules file
|
||||
cat > ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
# Configure ${CCW_CHAN_GROUP} device at ${CTC_READ_CHAN}/${CTC_WRITE_CHAN} (Protocol ${CTC_MODE})
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CTC_READ_CHAN", RUN+="/sbin/modprobe --quiet $CCW_CHAN_GROUP"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CTC_READ_CHAN", DRIVER!="?*", GOTO="ctc-${CTC_READ_CHAN}-no-unbind"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CTC_READ_CHAN", DRIVER=="ctcm", GOTO="ctc-${CTC_READ_CHAN}-no-unbind"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CTC_READ_CHAN", ATTR{driver/unbind}="$CTC_READ_CHAN"
|
||||
LABEL="ctc-${CTC_READ_CHAN}-no-unbind"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CTC_READ_CHAN", DRIVER!="?*", ATTR{[drivers/ccw:ctcm]bind}="$CTC_READ_CHAN"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CTC_WRITE_CHAN", DRIVER!="?*", GOTO="ctc-${CTC_WRITE_CHAN}-no-unbind"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CTC_WRITE_CHAN", DRIVER=="ctcm", GOTO="ctc-${CTC_WRITE_CHAN}-no-unbind"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CTC_WRITE_CHAN", ATTR{driver/unbind}="$CTC_WRITE_CHAN"
|
||||
LABEL="ctc-${CTC_WRITE_CHAN}-no-unbind"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CTC_WRITE_CHAN", DRIVER!="?*", ATTR{[drivers/ccw:ctcm]bind}="$CTC_WRITE_CHAN"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CTC_READ_CHAN", IMPORT{program}="collect $CCW_CHAN_ID %k $CTC_READ_CHAN $CTC_WRITE_CHAN $CCW_CHAN_GROUP"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CTC_WRITE_CHAN", RUN+="/sbin/modprobe --quiet $CCW_CHAN_GROUP"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CTC_WRITE_CHAN", IMPORT{program}="collect $CCW_CHAN_ID %k $CTC_READ_CHAN $CTC_WRITE_CHAN $CCW_CHAN_GROUP"
|
||||
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="$CCW_CHAN_GROUP", IMPORT{program}="collect $CCW_CHAN_ID %k $CTC_READ_CHAN $CTC_WRITE_CHAN $CCW_CHAN_GROUP"
|
||||
ACTION=="remove", SUBSYSTEM=="ccw", KERNEL=="$CTC_READ_CHAN", IMPORT{program}="collect --remove $CCW_CHAN_ID %k $CTC_READ_CHAN $CTC_WRITE_CHAN $CCW_CHAN_GROUP"
|
||||
ACTION=="remove", SUBSYSTEM=="ccw", KERNEL=="$CTC_WRITE_CHAN", IMPORT{program}="collect --remove $CCW_CHAN_ID %k $CTC_READ_CHAN $CTC_WRITE_CHAN $CCW_CHAN_GROUP"
|
||||
ACTION=="remove", SUBSYSTEM=="drivers", KERNEL=="$CCW_CHAN_GROUP", IMPORT{program}="collect --remove $CCW_CHAN_ID %k $CTC_READ_CHAN $CTC_WRITE_CHAN $CCW_CHAN_GROUP"
|
||||
TEST=="[ccwgroup/${CCW_CHAN_ID}]", GOTO="ctc-${CCW_CHAN_ID}-end"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", ENV{COLLECT_$CCW_CHAN_ID}=="0", ATTR{[drivers/ccwgroup:$CCW_CHAN_GROUP]group}="$CTC_READ_CHAN,$CTC_WRITE_CHAN"
|
||||
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="$CCW_CHAN_GROUP", ENV{COLLECT_$CCW_CHAN_ID}=="0", ATTR{group}="$CTC_READ_CHAN,$CTC_WRITE_CHAN"
|
||||
LABEL="ctc-${CCW_CHAN_ID}-end"
|
||||
EOF
|
||||
if [ "$CTC_MODE" -gt 0 ]; then
|
||||
cat >> ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
ACTION=="add", SUBSYSTEM=="ccwgroup", KERNEL=="$CCW_CHAN_ID", ATTR{protocol}="$CTC_MODE"
|
||||
EOF
|
||||
fi
|
||||
cat >> ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
ACTION=="add", SUBSYSTEM=="ccwgroup", KERNEL=="$CCW_CHAN_ID", ATTR{online}="1"
|
||||
EOF
|
||||
fi
|
||||
if [ ${ON_OFF} == 1 ]; then
|
||||
add_cio_channel "${CTC_READ_CHAN},${CTC_WRITE_CHAN}"
|
||||
else remove_cio_channel "${CTC_READ_CHAN}"
|
||||
remove_cio_channel "${CTC_WRITE_CHAN}"
|
||||
fi
|
||||
|
475
dasd_configure
475
dasd_configure
@ -1,409 +1,146 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# dasd_configure
|
||||
# $Id: dasd_configure,v 1.10 2004/11/26 15:50:48 hare Exp $
|
||||
#
|
||||
# Copyright (c) 2001-2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# Configures or deconfigures a DASD device
|
||||
# Configures a DASD device by calling the IBM-provided chzdev command.
|
||||
# Whereas this script used to validate the parameters provided to it,
|
||||
# we now rely on chzdev to do that instead. The script is intended only
|
||||
# as a "translation layer" to provide backward compatability for older
|
||||
# scripts and tools that invoke it.
|
||||
#
|
||||
# Usage:
|
||||
# dasd_configure [-f -t <dasd_type> ] <ccwid> <online> [use_diag]
|
||||
#
|
||||
# -f force creation of udev rules, do not check values in /sys.
|
||||
# -t DASD type. Must be provided if -f is used.
|
||||
# -f Override safety checks
|
||||
# -t DASD type. Must be provided if -f is used. Only dasd-eckd and
|
||||
# dasd-fba are supported - Deprecated
|
||||
# ccwid = 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.
|
||||
# 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
|
||||
# use_diag = 0 to _not_ use z/VM DIAG250 I/O, which is the default
|
||||
# 1 to use z/VM DIAG250 I/O
|
||||
#
|
||||
# Return values:
|
||||
# 1 If the "Usage:" line is displayed, not enough parameters specified.
|
||||
# 1 sysfs not mounted (if the "Usage:" line is not displayed).
|
||||
# 2 Invalid status for <online>
|
||||
# 3 No device found for <ccwid>
|
||||
# 4 Could not change state of the device
|
||||
# 5 Device is not a DASD
|
||||
# 6 Could not load module
|
||||
# 7 Failed to activate DASD
|
||||
# 8 DASD not formatted
|
||||
# 9 Only dasd-fba or dasd-eckd is supported.
|
||||
# Return codes are determined by the chzdev command.
|
||||
#
|
||||
|
||||
if [ "${DEBUG}" != "yes" ]; then
|
||||
DEBUG="no"
|
||||
fi
|
||||
|
||||
exitcode=0
|
||||
DASD_FORCE=0
|
||||
DASD_TYPE="unknown"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
mesg () {
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
debug_mesg () {
|
||||
case "$DEBUG" in
|
||||
case "${DEBUG}" in
|
||||
yes) mesg "$@" ;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [ $# -lt 2 ] ; then
|
||||
echo "Usage: $0 [options] <ccwid> <online> [use_diag]"
|
||||
echo
|
||||
echo " -f force creation of udev rules, do not check values in /sys."
|
||||
echo " -t DASD type. Must be provided if -f is used."
|
||||
echo " ccwid = 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"
|
||||
echo " use_diag = 0 to _not_ use z/VM DIAG250 I/O, which is the default"
|
||||
echo " 1 to use z/VM DIAG250 I/O"
|
||||
exit 1
|
||||
add_cio_channel() {
|
||||
echo "$* # ${DATE}" >> /boot/zipl/active_devices.txt
|
||||
}
|
||||
|
||||
remove_cio_channel() {
|
||||
[ -w /boot/zipl/active_devices.txt ] && sed -i -e "/^${1}/d" /boot/zipl/active_devices.txt
|
||||
}
|
||||
|
||||
usage(){
|
||||
echo "Usage: ${0} [-f -t <dasd_type> ] <ccwid> <online> [use_diag]"
|
||||
echo
|
||||
echo " -f Override safety checks"
|
||||
echo " -t DASD type. Must be provided if -f is used. Only dasd-eckd and"
|
||||
echo " dasd-fba are supported - Deprecated"
|
||||
echo " ccwid = 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"
|
||||
echo " this is 0, but it could be non-zero"
|
||||
echo " ssss is the four digit subchannel address of the device, in"
|
||||
echo " hexidecimal, with leading zeros."
|
||||
echo " online = 0 to take the device offline"
|
||||
echo " 1 to bring the device online"
|
||||
echo " use_diag = 0 to _not_ use z/VM DIAG250 I/O, which is the default"
|
||||
echo " 1 to use z/VM DIAG250 I/O"
|
||||
}
|
||||
|
||||
if [ "${DEBUG}" != "yes" ]; then
|
||||
DEBUG="no"
|
||||
fi
|
||||
|
||||
while [ $# -gt 0 ] ; do
|
||||
case "$1" in
|
||||
-f) # force creation of udev rules, do not check values in /sys
|
||||
DASD_FORCE=1
|
||||
;;
|
||||
-t*) # drive type. Must be provided if -f is used.
|
||||
if [ "$1" = "-t" ] ; then
|
||||
if [ "$2" = "dasd-eckd" -o "$2" = "dasd-fba" ]; then
|
||||
DASD_TYPE=$2
|
||||
shift
|
||||
else
|
||||
debug_mesg "Only dasd-eckd or dasd-fba are supported."
|
||||
exit 9
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
break;
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
DATE=$(date)
|
||||
|
||||
DASD_FORCE=0
|
||||
|
||||
############################################################
|
||||
# Parse the parameters from the command line
|
||||
#
|
||||
ARGS=$(getopt --options ft: -n "dasd_configure" -- "$@")
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
eval set -- "${ARGS}"
|
||||
debug_mesg "All the parms passed were ${ARGS}"
|
||||
|
||||
while true; do
|
||||
case "${1}" in
|
||||
-f) debug_mesg "This used to mean udev rules will always be generated."
|
||||
debug_mesg "For chzdev, it means safety checks will be overridden."
|
||||
debug_mesg "Kinda sorta the same thing, really."
|
||||
PARM_LIST="${PARM_LIST} -f"
|
||||
DASD_FORCE=1
|
||||
shift 1
|
||||
;;
|
||||
-t) debug_mesg "This used to set the card type to ${2}"
|
||||
debug_mesg "Now it gets ignored."
|
||||
shift 2
|
||||
;;
|
||||
--) debug_mesg "Found the end of parms indicator: --"
|
||||
shift 1
|
||||
break
|
||||
;;
|
||||
*) debug_mesg "At the catch-all select entry"
|
||||
debug_mesg "What was selected was ${1}"
|
||||
shift 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $DASD_FORCE -eq 0 ]; then
|
||||
# Get the mount point for sysfs
|
||||
while read MNTPT MNTDIR MNTSYS MNTTYPE; do
|
||||
if test "$MNTSYS" = "sysfs"; then
|
||||
SYSFS="$MNTDIR"
|
||||
break;
|
||||
fi
|
||||
done </proc/mounts
|
||||
CCW_CHAN_ID=${1}
|
||||
ON_OFF=${2}
|
||||
USE_DIAG=${3}
|
||||
|
||||
if [ -z "$SYSFS" ]; then
|
||||
mesg "/sysfs not present"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
CCW_CHAN_NAME=$DASD_TYPE
|
||||
case $DASD_TYPE in
|
||||
*eckd)
|
||||
DISCIPLINE=ECKD
|
||||
;;
|
||||
*fba)
|
||||
DISCIPLINE=FBA
|
||||
;;
|
||||
*)
|
||||
mesg "Only dasd-eckd or dasd-fba are supported."
|
||||
exit 9
|
||||
;;
|
||||
esac
|
||||
fi # First instance of if [ $DASD_FORCE -eq 0 ]
|
||||
|
||||
CCW_CHAN_ID=$1
|
||||
ONLINE=$2
|
||||
USE_DIAG=$3
|
||||
|
||||
[ -z "$USE_DIAG" ] && USE_DIAG=0
|
||||
|
||||
if [ -z "$ONLINE" ] || [ "$ONLINE" -ne "1" -a "$ONLINE" -ne "0" ]; then
|
||||
mesg "Invalid device status $ONLINE"
|
||||
mesg "It must be a zero or a one."
|
||||
exit 2
|
||||
if [ -z "${CCW_CHAN_ID}" ] || [ -z "${ON_OFF}" ]; then
|
||||
mesg "You didn't specify all the needed parameters."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $DASD_FORCE -eq 0 ]; then
|
||||
_ccw_dir=${SYSFS}/bus/ccw/devices
|
||||
|
||||
debug_mesg "Configuring device ${CCW_CHAN_ID}"
|
||||
_ccw_status_dir="$_ccw_dir/$CCW_CHAN_ID"
|
||||
|
||||
if test ! -d "$_ccw_status_dir" ; then
|
||||
if test "$ONLINE" -eq 1 ; then
|
||||
mesg "No device ${CCW_CHAN_ID}"
|
||||
exit 3
|
||||
fi
|
||||
_ccw_dev_status=0
|
||||
else
|
||||
read _cu_type < $_ccw_status_dir/cutype
|
||||
read _dev_type < $_ccw_status_dir/devtype
|
||||
|
||||
case "$_cu_type" in
|
||||
3990/*|2105/*|2107/*|1750/*|9343/*)
|
||||
CCW_CHAN_NAME="dasd-eckd"
|
||||
MODULE=dasd_eckd_mod
|
||||
DISCIPLINE=ECKD
|
||||
;;
|
||||
6310/*)
|
||||
CCW_CHAN_NAME="dasd-fba"
|
||||
MODULE=dasd_fba_mod
|
||||
DISCIPLINE=FBA
|
||||
;;
|
||||
3880/*)
|
||||
case "$_dev_type" in
|
||||
3390/*)
|
||||
CCW_CHAN_NAME="dasd-eckd"
|
||||
MODULE=dasd_eckd_mod
|
||||
DISCIPLINE=ECKD
|
||||
;;
|
||||
3370/*)
|
||||
CCW_CHAN_NAME="dasd-fba"
|
||||
MODULE=dasd_fba_mod
|
||||
DISCIPLINE=FBA
|
||||
;;
|
||||
*)
|
||||
CCW_CHAN_NAME=
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
CCW_CHAN_NAME=
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$CCW_CHAN_NAME" ]; then
|
||||
mesg "Not a DASD device (cu $_cutype, dev $_devtype)"
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# Check for modules
|
||||
if test ! -d "${SYSFS}/bus/ccw/drivers/${CCW_CHAN_NAME}" ; then
|
||||
/sbin/modprobe $MODULE
|
||||
|
||||
# Re-check whether module loading has succeeded
|
||||
if test ! -d "${SYSFS}/bus/ccw/drivers/${CCW_CHAN_NAME}"; then
|
||||
mesg "Could not load module ${MODULE}"
|
||||
exit 6
|
||||
fi
|
||||
fi
|
||||
|
||||
read _ccw_dev_status < $_ccw_status_dir/online
|
||||
fi # if test ! -d "$_ccw_status_dir"
|
||||
|
||||
#
|
||||
# We check whether we are running under z/VM by looking for the string
|
||||
# "Control Program: z/VM" in /proc/sysinfo
|
||||
#
|
||||
/bin/grep "Control Program: z/VM" /proc/sysinfo 2>&1 > /dev/null
|
||||
if [ -x /sbin/vmcp -a $? -eq 0 ]; then
|
||||
# Unconditionally load the vmcp module, loader might be broken
|
||||
[ -x /sbin/modprobe ] && /sbin/modprobe -q vmcp
|
||||
# Wait until udev is settled
|
||||
[ -x /sbin/udevadm ] && /sbin/udevadm settle --timeout=30
|
||||
|
||||
# Check read-only status of virtual DASDs from z/VM
|
||||
if /sbin/vmcp q v dasd > /dasd_attr.lst 2> /dev/null; then
|
||||
while read x dev type label attr1 attr2 rest; do
|
||||
dev=`echo $dev|tr A-F a-f`
|
||||
if test "$type" = "ON"; then
|
||||
attr="$attr2"
|
||||
else
|
||||
attr="$attr1"
|
||||
fi
|
||||
if [ "$CCW_CHAN_ID" = "0.0.$dev" ]; then
|
||||
if test "$attr" = "R/O"; then
|
||||
_ccw_use_readonly="1"
|
||||
fi
|
||||
fi
|
||||
done < /dasd_attr.lst
|
||||
fi
|
||||
rm -f /dasd_attr.lst
|
||||
fi # if [ -x /sbin/vmcp -a $? -eq 0 ]
|
||||
|
||||
if [ "$ONLINE" -eq 1 ]; then
|
||||
# Check whether we need to do something
|
||||
read _ccw_use_diag < $_ccw_status_dir/use_diag
|
||||
|
||||
if [ "$_ccw_use_diag" -ne "$USE_DIAG" ] &&
|
||||
[ "$_ccw_dev_status" -eq 1 ] ; then
|
||||
# We need to change the DIAG access mode
|
||||
# so we have to set the device offline first
|
||||
debug_mesg "Setting device offline for DIAG access"
|
||||
echo "0" > $_ccw_status_dir/online
|
||||
# Re-read device status
|
||||
read _ccw_dev_status < $_ccw_status_dir/online
|
||||
if [ "$_ccw_dev_status" -ne 0 ]; then
|
||||
mesg "Could not set the device offline for DIAG access"
|
||||
exit 4
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$_ccw_dev_status" -eq 0 ]; then
|
||||
# Set readonly access if detected
|
||||
if [ "$_ccw_use_readonly" ]; then
|
||||
debug_mesg "Setting device read-only"
|
||||
echo 1 > $_ccw_status_dir/readonly
|
||||
fi
|
||||
|
||||
if [ "$USE_DIAG" -eq 1 ]; then
|
||||
# Load the diag module if possible
|
||||
[ -x /sbin/modprobe ] && /sbin/modprobe -q dasd_diag_mod
|
||||
_has_dasd_diag=$(/bin/sed -n '/^dasd_diag_mod/p' /proc/modules)
|
||||
if [ "$_has_dasd_diag" ]; then
|
||||
# DIAG mode is special:
|
||||
# We can only be sure if DIAG is available
|
||||
# _after_ we have activated the device
|
||||
debug_mesg "Activating DIAG access mode"
|
||||
echo "$USE_DIAG" > $_ccw_status_dir/use_diag
|
||||
read _ccw_use_diag < $_ccw_status_dir/use_diag
|
||||
# Set the device online
|
||||
debug_mesg "Setting device online"
|
||||
echo "1" > $_ccw_status_dir/online 2>/dev/null
|
||||
# Re-read device status
|
||||
read _ccw_dev_status < $_ccw_status_dir/online
|
||||
if [ "$_ccw_dev_status" -eq 0 ]; then
|
||||
mesg "Could not activate DIAG access mode for device ${CCW_CHAN_ID}"
|
||||
USE_DIAG=0
|
||||
echo "$USE_DIAG" > $_ccw_status_dir/use_diag
|
||||
# Set the device online
|
||||
debug_mesg "Setting device online"
|
||||
echo "1" > $_ccw_status_dir/online
|
||||
else
|
||||
MODULE=dasd_diag_mod
|
||||
fi
|
||||
else
|
||||
debug_mesg "DIAG mode not available"
|
||||
USE_DIAG=0
|
||||
# Set the device online
|
||||
debug_mesg "Setting device online"
|
||||
echo "1" > $_ccw_status_dir/online
|
||||
fi # if [ "$_has_dasd_diag" ];
|
||||
else
|
||||
if [ "$_ccw_use_diag" -eq 1 ] ; then
|
||||
debug_mesg "Deactivating DIAG access mode"
|
||||
echo "0" > $_ccw_status_dir/use_diag
|
||||
read _ccw_use_diag < $_ccw_status_dir/use_diag
|
||||
fi
|
||||
# Set the device online
|
||||
debug_mesg "Setting device online"
|
||||
echo "1" > $_ccw_status_dir/online
|
||||
fi # if [ "$USE_DIAG" -eq 1 ]
|
||||
|
||||
# Re-read device status
|
||||
read _ccw_dev_status < $_ccw_status_dir/online
|
||||
if [ "$_ccw_dev_status" -eq 0 ]; then
|
||||
mesg "Could not set device ${CCW_CHAN_ID} online"
|
||||
exit 4
|
||||
fi
|
||||
|
||||
# Wait for the device to come online
|
||||
read _dasd_state < $_ccw_status_dir/status
|
||||
i=0
|
||||
while [ "$_dasd_state" != "online" ] ; do
|
||||
if [ "$_dasd_state" = "unformatted" ] ; then
|
||||
mesg "Device ${CCW_CHAN_ID} is unformatted"
|
||||
exitcode=8
|
||||
break
|
||||
fi
|
||||
[ $i -gt 30 ] && break
|
||||
i=$(expr $i + 1)
|
||||
sleep .1
|
||||
read _dasd_state < $_ccw_status_dir/status
|
||||
done
|
||||
else
|
||||
debug_mesg "Device ${CCW_CHAN_ID} is already online"
|
||||
fi # if [ "$_ccw_dev_status" -eq 0 ]
|
||||
|
||||
read _dasd_state < $_ccw_status_dir/status
|
||||
if [ "$_dasd_state" != "online" ] && [ "$_dasd_state" != "unformatted" ] ; then
|
||||
mesg "Failed to activate device ${CCW_CHAN_ID}, device in state $_dasd_state"
|
||||
exit 7
|
||||
fi
|
||||
else
|
||||
if [ "$_ccw_dev_status" -eq 1 ]; then
|
||||
# Set the device offline
|
||||
debug_mesg "Setting device offline"
|
||||
echo "$ONLINE" > $_ccw_status_dir/online
|
||||
|
||||
# Re-read to check whether we have succeeded
|
||||
_ccw_dev_status=$(cat $_ccw_status_dir/online)
|
||||
if [ "$?" -ne 0 -o "$_ccw_dev_status" -ne "$ONLINE" ]; then
|
||||
mesg "Could not set device ${CCW_CHAN_ID} offline"
|
||||
exit 4
|
||||
fi
|
||||
else
|
||||
debug_mesg "Device ${CCW_CHAN_ID} is already offline"
|
||||
fi
|
||||
|
||||
if [ -d "$_ccw_status_dir" ] ; then
|
||||
# Always disabling DIAG access
|
||||
echo "0" > $_ccw_status_dir/use_diag
|
||||
fi
|
||||
|
||||
# Set readonly access if detected
|
||||
if [ "$_ccw_use_readonly" ]; then
|
||||
debug_mesg "Setting device read-only"
|
||||
echo 1 > $_ccw_status_dir/readonly
|
||||
fi
|
||||
fi # if [ "$ONLINE" -eq 1 ]
|
||||
|
||||
# Wait until udev is settled
|
||||
[ -x /sbin/udevadm ] && /sbin/udevadm settle --timeout=30
|
||||
|
||||
fi # Second instance of if [ $DASD_FORCE -eq 0 ]
|
||||
|
||||
if [ $DEBUG = "no" ]; then
|
||||
RULES_DIR=/etc/udev/rules.d
|
||||
else
|
||||
RULES_DIR=.
|
||||
if [ -n "${USE_DIAG}" ]; then
|
||||
PARM_LIST="${PARM_LIST} use_diag=${USE_DIAG}"
|
||||
else PARM_LIST="${PARM_LIST} use_diag=0"
|
||||
fi
|
||||
|
||||
RULES_FILE=51-dasd-${CCW_CHAN_ID}.rules
|
||||
|
||||
if [ -d "$RULES_DIR" ]; then
|
||||
if [ -f ${RULES_DIR}/${RULES_FILE} ]; then
|
||||
rm -f ${RULES_DIR}/${RULES_FILE}
|
||||
fi
|
||||
remove_channel_for_cio "${CCW_CHAN_ID}"
|
||||
|
||||
if [ "$ONLINE" -eq "1" ]; then
|
||||
add_channel_for_cio "${CCW_CHAN_ID}"
|
||||
# Write a new hwcfg file
|
||||
cat > ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
# Configure DASD device at ${CCW_CHAN_ID} (${DISCIPLINE} mode)
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="${CCW_CHAN_ID}", IMPORT{program}="collect ${CCW_CHAN_ID} %k ${CCW_CHAN_ID} ${CCW_CHAN_NAME}"
|
||||
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="${CCW_CHAN_NAME}", IMPORT{program}="collect ${CCW_CHAN_ID} %k ${CCW_CHAN_ID} ${CCW_CHAN_NAME}"
|
||||
EOF
|
||||
if [ "$USE_DIAG" -eq 1 ]; then
|
||||
cat >> ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
ACTION=="add", ENV{COLLECT_${CCW_CHAN_ID}}=="0", ATTR{[ccw/$CCW_CHAN_ID]use_diag}="1"
|
||||
EOF
|
||||
fi
|
||||
cat >> ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
ACTION=="add", ENV{COLLECT_${CCW_CHAN_ID}}=="0", ATTR{[ccw/$CCW_CHAN_ID]online}="1"
|
||||
EOF
|
||||
fi
|
||||
if [ "${ON_OFF}" == 0 ]; then
|
||||
debug_mesg "chzdev -d dasd ${CCW_CHAN_ID}"
|
||||
chzdev -d dasd ${CCW_CHAN_ID}
|
||||
elif [ "${ON_OFF}" == 1 ]; then
|
||||
debug_mesg "chzdev -e dasd ${CCW_CHAN_ID} ${PARM_LIST}"
|
||||
chzdev -e dasd ${CCW_CHAN_ID} ${PARM_LIST}
|
||||
else mesg "You must specify a 0 or a 1 for the online/offline attribute."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit $exitcode
|
||||
RC=${?}
|
||||
if [ ${RC} -ne 0 ]; then
|
||||
exit ${RC}
|
||||
fi
|
||||
|
||||
if [ ${ON_OFF} == 1 ]; then
|
||||
add_cio_channel "${CCW_CHAN_ID}"
|
||||
else remove_cio_channel "${CCW_CHAN_ID}"
|
||||
fi
|
||||
|
554
qeth_configure
554
qeth_configure
@ -2,451 +2,173 @@
|
||||
#
|
||||
# qeth_configure
|
||||
#
|
||||
# Configures a qeth device
|
||||
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# Configures a qeth device by calling the IBM-provided chzdev command.
|
||||
# Whereas this script used to validate the parameters provided to it,
|
||||
# we now rely on chzdev to do that instead. The script is intended only
|
||||
# as a "translation layer" to provide backward compatability for older
|
||||
# scripts and tools that invoke it.
|
||||
#
|
||||
# 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
|
||||
# -f Override safety checks
|
||||
# -t Valid cardtypes are: qeth, hsi - Deprecated
|
||||
# -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.
|
||||
# -n QETH port number to use, 0 or 1. Only needed for real, not virtual
|
||||
# devices.
|
||||
# -p QETH Portname to use - Deprecated. OSAs no longer need a port name.
|
||||
# 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.
|
||||
# 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
|
||||
# Return codes are determined by the chzdev command.
|
||||
#
|
||||
|
||||
if [ "${DEBUG}" != "yes" ]; then
|
||||
DEBUG="no"
|
||||
fi
|
||||
|
||||
QETH_FORCE=0
|
||||
|
||||
mesg () {
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
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 "$@" ;;
|
||||
*) ;;
|
||||
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
|
||||
QETH_FORCE=1
|
||||
;;
|
||||
-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. Must be provided if -f is used.
|
||||
if [ "$1" = "-t" ] ; then
|
||||
if [ "$2" = "qeth" -o "$2" = "hsi" -o "$2" = "osn" ]; then
|
||||
QETH_CARD=$2
|
||||
shift
|
||||
else
|
||||
mesg "Only qeth, hsi and osn are supported."
|
||||
exit 6
|
||||
fi
|
||||
fi
|
||||
CCW_DRV="$QETH_CARD"
|
||||
;;
|
||||
*)
|
||||
break;
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
add_cio_channel() {
|
||||
echo "$* # ${DATE}" >> /boot/zipl/active_devices.txt
|
||||
}
|
||||
|
||||
remove_cio_channel() {
|
||||
[ -w /boot/zipl/active_devices.txt ] && sed -i -e "/^${1}/d" /boot/zipl/active_devices.txt
|
||||
}
|
||||
|
||||
usage(){
|
||||
echo "Usage: ${0} [options] <read chan> <write chan> <data chan> <online>"
|
||||
echo " -i Configure IP takeover"
|
||||
echo " -l Configure Layer2 support"
|
||||
echo " -f Override safety checks"
|
||||
echo " -t Valid cardtypes are: qeth, hsi - Deprecated."
|
||||
echo " -o General QETH options, separated by spaces"
|
||||
echo " -n QETH port number to use, 0 or 1. Only needed for real, not virtual"
|
||||
echo " devices."
|
||||
echo " -p QETH Portname to use - Deprecated. OSAs no longer need a port name."
|
||||
echo " read/write/data chan = x.y.ssss where"
|
||||
echo " x is always 0 until IBM creates something that"
|
||||
echo " uses that number"
|
||||
echo " y is the logical channel subsystem (lcss)"
|
||||
echo " number. Most often this is 0, but it could"
|
||||
echo " be non-zero"
|
||||
echo " ssss is the four digit subchannel address of"
|
||||
echo " the device, in hexidecimal, with leading"
|
||||
echo " zeros."
|
||||
echo " online = 0 to take the device offline"
|
||||
echo " 1 to bring the device online"
|
||||
}
|
||||
|
||||
if [ "${DEBUG}" != "yes" ]; then
|
||||
DEBUG="no"
|
||||
fi
|
||||
|
||||
DATE=$(date)
|
||||
|
||||
############################################################
|
||||
# Parse the parameters from the command line
|
||||
#
|
||||
ARGS=$(getopt --options ifln:o:p:t: -n "qeth_configure" -- "$@")
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||
|
||||
eval set -- "${ARGS}"
|
||||
debug_mesg "All the parms passed were ${ARGS}"
|
||||
|
||||
# Set some defaults
|
||||
LAYER_MODE="layer2=0"
|
||||
|
||||
while true; do
|
||||
case "${1}" in
|
||||
-i) debug_mesg "Configure IP takeover"
|
||||
PARM_LIST="${PARM_LIST} ipa_takeover/enable=1"
|
||||
shift 1
|
||||
;;
|
||||
-f) debug_mesg "This used to mean udev rules will always be generated."
|
||||
debug_mesg "For chzdev, it means safety checks will be overridden."
|
||||
debug_mesg "Kinda sorta the same thing, really."
|
||||
PARM_LIST="${PARM_LIST} -f"
|
||||
shift 1
|
||||
;;
|
||||
-l) debug_mesg "Configure Layer 2 support"
|
||||
LAYER_MODE="layer2=1"
|
||||
shift 1
|
||||
;;
|
||||
-n) debug_mesg "Set QETH port number to ${2}"
|
||||
PARM_LIST="${PARM_LIST} portno=${2}"
|
||||
shift 2
|
||||
;;
|
||||
-o) debug_mesg "Add the following arbitrary parms: ${2}"
|
||||
PARM_LIST="${PARM_LIST} ${2}"
|
||||
shift 2
|
||||
;;
|
||||
-p) debug_mesg "QETH Port name is no longer used, don't specify it: ${2}"
|
||||
shift 2
|
||||
;;
|
||||
-t) debug_mesg "This used to set the card type to ${2}"
|
||||
debug_mesg "Now it gets ignored."
|
||||
shift 2
|
||||
;;
|
||||
--) debug_mesg "Found the end of parms indicator: --"
|
||||
shift 1
|
||||
break
|
||||
;;
|
||||
*) debug_mesg "At the catch-all select entry"
|
||||
debug_mesg "What was selected was ${1}"
|
||||
shift 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $QETH_FORCE -eq 0 ]; then
|
||||
# Get the mount point for sysfs
|
||||
while read MNTPT MNTDIR MNTSYS MNTTYPE; do
|
||||
if test "$MNTSYS" = "sysfs"; then
|
||||
SYSFS="$MNTDIR"
|
||||
break;
|
||||
fi
|
||||
done </proc/mounts
|
||||
QETH_READ_CHAN=${1}
|
||||
QETH_WRITE_CHAN=${2}
|
||||
QETH_DATA_CHAN=${3}
|
||||
ON_OFF=${4}
|
||||
|
||||
if [ -z "$SYSFS" ]; then
|
||||
mesg "/sysfs not present"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${QETH_READ_CHAN}" ] || [ -z "${QETH_WRITE_CHAN}" ] || [ -z "${QETH_DATA_CHAN}" ] || [ -z "${ON_OFF}" ]; then
|
||||
mesg "You didn't specify all the needed parameters."
|
||||
usage
|
||||
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
|
||||
if [ "${ON_OFF}" == 0 ]; then
|
||||
debug_mesg "chzdev -d qeth ${QETH_READ_CHAN}"
|
||||
chzdev -d qeth ${QETH_READ_CHAN}
|
||||
elif [ "${ON_OFF}" == 1 ]; then
|
||||
debug_mesg "chzdev -e qeth ${LAYER_MODE} ${PARM_LIST} ${QETH_READ_CHAN}"
|
||||
chzdev -e qeth ${LAYER_MODE} ${PARM_LIST} ${QETH_READ_CHAN}
|
||||
else mesg "You must specify a 0 or a 1 for the online/offline attribute."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$ONLINE" ] || [ "$ONLINE" -ne "1" -a "$ONLINE" -ne "0" ]; then
|
||||
mesg "Invalid device status $ONLINE"
|
||||
exit 2
|
||||
RC=${?}
|
||||
if [ ${RC} -ne 0 ]; then
|
||||
exit ${RC}
|
||||
fi
|
||||
|
||||
if [ $QETH_FORCE -eq 0 ]; then
|
||||
_ccw_dir=${SYSFS}/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
|
||||
mesg "No device ${QETH_READ_CHAN}"
|
||||
exit 3
|
||||
if [ ${ON_OFF} == 1 ]; then
|
||||
add_cio_channel "${QETH_READ_CHAN},${QETH_WRITE_CHAN},${QETH_DATA_CHAN}"
|
||||
else remove_cio_channel "${QETH_READ_CHAN}"
|
||||
remove_cio_channel "${QETH_WRITE_CHAN}"
|
||||
remove_cio_channel "${QETH_DATA_CHAN}"
|
||||
fi
|
||||
if test ! -d "$_ccw_dir/$QETH_WRITE_CHAN" ; then
|
||||
mesg "No device ${QETH_WRITE_CHAN}"
|
||||
exit 4
|
||||
fi
|
||||
if test ! -d "$_ccw_dir/$QETH_DATA_CHAN" ; then
|
||||
mesg "No device ${QETH_DATA_CHAN}"
|
||||
exit 5
|
||||
fi
|
||||
|
||||
CCW_CHAN_GROUP=
|
||||
for ccw in $_ccw_dir/$QETH_READ_CHAN $_ccw_dir/$QETH_WRITE_CHAN $_ccw_dir/$QETH_DATA_CHAN; do
|
||||
|
||||
read _cu_type < $ccw/cutype
|
||||
read _dev_type < $ccw/devtype
|
||||
|
||||
case "$_cu_type" in
|
||||
1731/01|1731/02)
|
||||
# OSA/Express / Guest LAN
|
||||
CCW_DRV="qeth"
|
||||
QETH_CARD="qeth"
|
||||
;;
|
||||
1731/05)
|
||||
# Hipersockets
|
||||
CCW_DRV="qeth"
|
||||
QETH_CARD="hsi"
|
||||
;;
|
||||
1731/06)
|
||||
# OSA/N
|
||||
CCW_DRV="qeth"
|
||||
QETH_CARD="osn"
|
||||
;;
|
||||
*)
|
||||
CCW_DRV=
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$CCW_DRV" ]; then
|
||||
mesg "Not a valid QETH device (cu $_cutype, dev $_devtype)"
|
||||
exit 6
|
||||
fi
|
||||
done
|
||||
fi # end QETH_FORCE
|
||||
|
||||
# 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
|
||||
|
||||
if [ $QETH_FORCE -eq 0 ]; then
|
||||
_ccw_groupdir=${SYSFS}/bus/ccwgroup
|
||||
|
||||
# Check for modules
|
||||
if test ! -d "${_ccw_groupdir}/drivers/${CCW_DRV}" ; then
|
||||
/sbin/modprobe $CCW_DRV
|
||||
|
||||
# Re-check whether module loading has succeeded
|
||||
if test ! -d "${_ccw_groupdir}/drivers/${CCW_DRV}"; then
|
||||
mesg "Could not load module ${CCW_DRV}"
|
||||
exit 7
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for grouping
|
||||
_ccwgroup_dir=
|
||||
if [ -e ${_ccw_dir}/${QETH_READ_CHAN}/group_device ] ; then
|
||||
_ccwgroup_dir=$(cd -P ${_ccw_dir}/${QETH_READ_CHAN}/group_device; echo $PWD)
|
||||
fi
|
||||
if [ -e ${_ccw_dir}/${QETH_WRITE_CHAN}/group_device ] ; then
|
||||
_tmp_status_dir=$(cd -P ${_ccw_dir}/${QETH_READ_CHAN}/group_device; echo $PWD)
|
||||
if [ "$_ccwgroup_dir" ] && [ "$_ccwgroup_dir" != "$_tmp_status_dir" ] ; then
|
||||
mesg "CCW devices grouped to different devices"
|
||||
exit 8
|
||||
fi
|
||||
_ccwgroup_dir=$_tmp_status_dir
|
||||
fi
|
||||
if [ -e ${_ccw_dir}/${QETH_DATA_CHAN}/group_device ] ; then
|
||||
_tmp_status_dir=$(cd -P ${_ccw_dir}/${QETH_DATA_CHAN}/group_device; echo $PWD)
|
||||
if [ "$_ccwgroup_dir" ] && [ "$_ccwgroup_dir" != "$_tmp_status_dir" ] ; then
|
||||
mesg "CCW devices grouped to different devices"
|
||||
exit 8
|
||||
fi
|
||||
_ccwgroup_dir=$_tmp_status_dir
|
||||
fi
|
||||
if [ -z "$_ccwgroup_dir" ] ; then
|
||||
echo "$QETH_READ_CHAN,$QETH_WRITE_CHAN,$QETH_DATA_CHAN" > ${_ccw_groupdir}/drivers/${CCW_DRV}/group
|
||||
if [ -e ${_ccw_dir}/${QETH_READ_CHAN}/group_device ] ; then
|
||||
_ccwgroup_dir=$(cd -P ${_ccw_dir}/${QETH_READ_CHAN}/group_device; echo $PWD)
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$_ccwgroup_dir" -o ! -e "$_ccwgroup_dir" ] ; then
|
||||
mesg "Could not group $CCW_DRV devices $QETH_READ_CHAN/$QETH_WRITE_CHAN/$QETH_DATA_CHAN"
|
||||
exit 9
|
||||
fi
|
||||
|
||||
CCW_CHAN_ID=${_ccwgroup_dir##*/}
|
||||
|
||||
read _online < $_ccwgroup_dir/online
|
||||
|
||||
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) "
|
||||
echo "$QETH_PORTNAME" > $_ccwgroup_dir/portname
|
||||
fi
|
||||
# Activate Layer2 support
|
||||
if [ -w "$_ccwgroup_dir/layer2" ] ; then
|
||||
if [ "$QETH_LAYER2_SUPPORT" = "1" ]; then
|
||||
mesg "(Layer2) "
|
||||
echo 1 > $_ccwgroup_dir/layer2
|
||||
else
|
||||
echo 0 > $_ccwgroup_dir/layer2
|
||||
fi
|
||||
else
|
||||
QETH_LAYER2_SUPPORT=
|
||||
fi
|
||||
# Enable IP address takeover
|
||||
if [ "$QETH_IPA_TAKEOVER" ]; then
|
||||
if [ "$QETH_IPA_TAKEOVER" = "1" ]; then
|
||||
mesg "(IP takeover) "
|
||||
echo 1 > $_ccwgroup_dir/ipa_takeover/enable
|
||||
fi
|
||||
fi
|
||||
# Relative port number
|
||||
if [ -w "$_ccwgroup_dir/portno" ] ; then
|
||||
if [ -n "$QETH_PORTNO" ]; then
|
||||
mesg "(Port $QETH_PORTNO) "
|
||||
# This may fail, but trial and error is the only way to tell.
|
||||
echo "$QETH_PORTNO" > $_ccwgroup_dir/portno
|
||||
fi
|
||||
else
|
||||
unset QETH_PORTNO
|
||||
fi
|
||||
# Set additional options
|
||||
if [ "$QETH_OPTIONS" ]; then
|
||||
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
|
||||
if [ $? -eq 0 ] ; then
|
||||
cur_opts="$cur_opts ${opt_name}=${opt_val}"
|
||||
fi
|
||||
else
|
||||
# Skip invalid options
|
||||
debug_mesg "Invalid option $opt_name"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# Update options list
|
||||
QETH_OPTIONS="$cur_opts"
|
||||
fi
|
||||
|
||||
echo "1" > $_ccwgroup_dir/online 2> /dev/null
|
||||
# Re-read device status
|
||||
read _ccw_dev_status < $_ccwgroup_dir/online
|
||||
if [ "$_ccw_dev_status" -eq 0 ]; then
|
||||
mesg "Could not set device ${CCW_CHAN_ID} online"
|
||||
exit 10
|
||||
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
|
||||
|
||||
# Re-read to check whether we have succeeded
|
||||
_online=$(cat $_ccwgroup_dir/online)
|
||||
if [ "$_online" -ne "$ONLINE" ]; then
|
||||
mesg "Could not set device ${CCW_CHAN_ID} offline"
|
||||
exit 11
|
||||
fi
|
||||
else
|
||||
debug_mesg "Device ${CCW_CHAN_ID} is already offline"
|
||||
fi
|
||||
echo 1 > $_ccwgroup_dir/ungroup
|
||||
fi
|
||||
else
|
||||
CCW_CHAN_ID=$QETH_READ_CHAN
|
||||
fi # QETH_FORCE
|
||||
|
||||
if [ $DEBUG = "no" ]; then
|
||||
RULES_DIR=/etc/udev/rules.d
|
||||
else
|
||||
RULES_DIR=.
|
||||
fi
|
||||
|
||||
RULES_FILE=51-${QETH_CARD}-${CCW_CHAN_ID}.rules
|
||||
|
||||
if [ -d "$RULES_DIR" ]; then
|
||||
if [ -f ${RULES_DIR}/${RULES_FILE} ]; then
|
||||
rm -f ${RULES_DIR}/${RULES_FILE}
|
||||
fi
|
||||
remove_channel_for_cio "${QETH_READ_CHAN}"
|
||||
remove_channel_for_cio "${QETH_WRITE_CHAN}"
|
||||
remove_channel_for_cio "${QETH_DATA_CHAN}"
|
||||
|
||||
if [ "$ONLINE" -eq "1" ]; then
|
||||
add_channel_for_cio "${QETH_READ_CHAN},${QETH_WRITE_CHAN},${QETH_DATA_CHAN}"
|
||||
# Write a new udev rules file
|
||||
cat > ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
# Configure ${QETH_CARD} device at ${QETH_READ_CHAN}/${QETH_WRITE_CHAN}/${QETH_DATA_CHAN}
|
||||
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="$CCW_DRV", IMPORT{program}="collect $CCW_CHAN_ID %k $QETH_READ_CHAN $QETH_WRITE_CHAN $QETH_DATA_CHAN $CCW_DRV"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$QETH_READ_CHAN", IMPORT{program}="collect $CCW_CHAN_ID %k $QETH_READ_CHAN $QETH_WRITE_CHAN $QETH_DATA_CHAN $CCW_DRV"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$QETH_WRITE_CHAN", IMPORT{program}="collect $CCW_CHAN_ID %k $QETH_READ_CHAN $QETH_WRITE_CHAN $QETH_DATA_CHAN $CCW_DRV"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$QETH_DATA_CHAN", IMPORT{program}="collect $CCW_CHAN_ID %k $QETH_READ_CHAN $QETH_WRITE_CHAN $QETH_DATA_CHAN $CCW_DRV"
|
||||
ACTION=="remove", SUBSYSTEM=="drivers", KERNEL=="$CCW_DRV", IMPORT{program}="collect --remove $CCW_CHAN_ID %k $QETH_READ_CHAN $QETH_WRITE_CHAN $QETH_DATA_CHAN $CCW_DRV"
|
||||
ACTION=="remove", SUBSYSTEM=="ccw", KERNEL=="$QETH_READ_CHAN", IMPORT{program}="collect --remove $CCW_CHAN_ID %k $QETH_READ_CHAN $QETH_WRITE_CHAN $QETH_DATA_CHAN $CCW_DRV"
|
||||
ACTION=="remove", SUBSYSTEM=="ccw", KERNEL=="$QETH_WRITE_CHAN", IMPORT{program}="collect --remove $CCW_CHAN_ID %k $QETH_READ_CHAN $QETH_WRITE_CHAN $QETH_DATA_CHAN $CCW_DRV"
|
||||
ACTION=="remove", SUBSYSTEM=="ccw", KERNEL=="$QETH_DATA_CHAN", IMPORT{program}="collect --remove $CCW_CHAN_ID %k $QETH_READ_CHAN $QETH_WRITE_CHAN $QETH_DATA_CHAN $CCW_DRV"
|
||||
TEST=="[ccwgroup/${CCW_CHAN_ID}]", GOTO="${QETH_CARD}-${CCW_CHAN_ID}-end"
|
||||
ACTION=="add", SUBSYSTEM=="ccw", ENV{COLLECT_$CCW_CHAN_ID}=="0", ATTR{[drivers/ccwgroup:$CCW_DRV]group}="$QETH_READ_CHAN,$QETH_WRITE_CHAN,$QETH_DATA_CHAN"
|
||||
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="$CCW_DRV", ENV{COLLECT_$CCW_CHAN_ID}=="0", ATTR{[drivers/ccwgroup:$CCW_DRV]group}="$QETH_READ_CHAN,$QETH_WRITE_CHAN,$QETH_DATA_CHAN"
|
||||
LABEL="${QETH_CARD}-${CCW_CHAN_ID}-end"
|
||||
EOF
|
||||
if [ "$QETH_PORTNAME" ]; then
|
||||
cat >> ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
ACTION=="add", SUBSYSTEM=="ccwgroup", KERNEL=="$CCW_CHAN_ID", ATTR{portname}="$QETH_PORTNAME"
|
||||
EOF
|
||||
fi
|
||||
if [ "$QETH_PORTNO" ]; then
|
||||
cat >> ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
ACTION=="add", SUBSYSTEM=="ccwgroup", KERNEL=="$CCW_CHAN_ID", ATTR{portno}="$QETH_PORTNO"
|
||||
EOF
|
||||
fi
|
||||
if [ "$QETH_LAYER2_SUPPORT" ]; then
|
||||
cat >> ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
ACTION=="add", SUBSYSTEM=="ccwgroup", KERNEL=="$CCW_CHAN_ID", ATTR{layer2}="1"
|
||||
EOF
|
||||
elif [ "${QETH_CARD}" != "osn" ]; then
|
||||
cat >> ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
ACTION=="add", SUBSYSTEM=="ccwgroup", KERNEL=="$CCW_CHAN_ID", ATTR{layer2}="0"
|
||||
EOF
|
||||
fi
|
||||
if [ "$QETH_IPA_TAKEOVER" ]; then
|
||||
cat >> ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
ACTION=="add", SUBSYSTEM=="ccwgroup", KERNEL=="$CCW_CHAN_ID", ATTR{ipa_takeover/enable}="1"
|
||||
EOF
|
||||
fi
|
||||
for opt in $QETH_OPTIONS; do
|
||||
set -- $(IFS='='; echo $opt)
|
||||
opt_name=$1
|
||||
opt_val=$2
|
||||
cat >> ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
ACTION=="add", SUBSYSTEM=="ccwgroup", KERNEL=="$CCW_CHAN_ID", ATTR{$opt_name}="$opt_val"
|
||||
EOF
|
||||
done
|
||||
cat >> ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
ACTION=="add", SUBSYSTEM=="ccwgroup", KERNEL=="$CCW_CHAN_ID", ATTR{online}="1"
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
udevadm settle
|
||||
|
||||
exit 0
|
||||
|
@ -1,3 +1,11 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Nov 9 20:39:38 UTC 2017 - mpost@suse.com
|
||||
|
||||
- Updated the cputype script to recognize the new IBM z14
|
||||
processor (bsc#1049843).
|
||||
- Re-instated the new versions of ctc_configure, dasd_configure,
|
||||
qeth_configure, zfcp_disk_configure, zfcp_host_configure.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Oct 25 17:21:30 UTC 2017 - mpost@suse.com
|
||||
|
||||
|
@ -2,318 +2,72 @@
|
||||
#
|
||||
# zfcp_disk_configure
|
||||
#
|
||||
# Configures a zfcp disk
|
||||
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# Configures a zfcp SCSI disk by calling the IBM-provided chzdev command.
|
||||
# Whereas this script used to validate the parameters provided to it,
|
||||
# we now rely on chzdev to do that instead. The script is intended only
|
||||
# as a "translation layer" to provide backward compatability for older
|
||||
# scripts and tools that invoke it.
|
||||
#
|
||||
# Usage:
|
||||
# zfcp_disk_configure <ccwid> <wwpn> <lun> <online>
|
||||
#
|
||||
# ccwid = 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.
|
||||
# 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 codes
|
||||
# 1 sysfs not mounted
|
||||
# 2 invalid value for <online>
|
||||
# 3 device <ccwid> does not exist
|
||||
# 4 WWPN invalid
|
||||
# 5 Could not activate WWPN for adapter
|
||||
# 6 Could not activate zFCP disk
|
||||
# 7 SCSI disk could not be deactivated
|
||||
# 8 zFCP LUN could not be deregistered
|
||||
# 9 zFCP WWPN could not be deregistered
|
||||
# Return values:
|
||||
# Return codes are determined by the chzdev command.
|
||||
#
|
||||
|
||||
if [ "${DEBUG}" != "yes" ]; then
|
||||
DEBUG="no"
|
||||
fi
|
||||
|
||||
mesg () {
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
debug_mesg () {
|
||||
case "$DEBUG" in
|
||||
yes) mesg "$@" ;;
|
||||
*) ;;
|
||||
case "${DEBUG}" in
|
||||
yes) mesg "$@" ;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [ $# -ne 4 ] ; then
|
||||
echo "Usage: $0 <ccwid> <wwpn> <lun> <online>"
|
||||
echo " ccwid = 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
|
||||
usage(){
|
||||
echo "Usage: ${0} <ccwid> <wwpn> <lun> <online>"
|
||||
echo " ccwid = 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"
|
||||
echo " this is 0, but it could be non-zero"
|
||||
echo " ssss is the four digit subchannel address of the device, in"
|
||||
echo " hexidecimal, with leading zeros."
|
||||
echo " online = 0 to take the device offline"
|
||||
echo " 1 to bring the device online"
|
||||
}
|
||||
|
||||
if [ "${DEBUG}" != "yes" ]; then
|
||||
DEBUG="no"
|
||||
fi
|
||||
|
||||
# Get the mount point for sysfs
|
||||
while read MNTPT MNTDIR MNTSYS MNTTYPE; do
|
||||
if test "$MNTSYS" = "sysfs"; then
|
||||
SYSFS="$MNTDIR"
|
||||
break;
|
||||
fi
|
||||
done </proc/mounts
|
||||
|
||||
if [ -z "$SYSFS" ]; then
|
||||
mesg "/sysfs not present"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
udev_timeout=30
|
||||
CCW_CHAN_ID=$1
|
||||
FCP_WWPN=${2#0x*}
|
||||
FCP_LUN=${3#0x*}
|
||||
ONLINE=$4
|
||||
CCW_CHAN_ID=${1}
|
||||
FCP_WWPN="${2}"
|
||||
FCP_LUN="${3}"
|
||||
ON_OFF=${4}
|
||||
# normalise to lower case
|
||||
FCP_WWPN=`echo $FCP_WWPN | sed 's/A/a/g;s/B/b/g;s/C/c/g;s/D/d/g;s/E/e/g;s/F/f/g'`
|
||||
FCP_LUN=`echo $FCP_LUN | sed 's/A/a/g;s/B/b/g;s/C/c/g;s/D/d/g;s/E/e/g;s/F/f/g'`
|
||||
FCP_WWPN=$(echo ${FCP_WWPN} | tr "A-Z" "a-z")
|
||||
FCP_LUN=$(echo ${FCP_LUN} | tr "A-Z" "a-z")
|
||||
|
||||
if [ -z "$CCW_CHAN_ID" ] ; then
|
||||
mesg "No CCW device specified"
|
||||
exit 1
|
||||
if [ "${ON_OFF}" == 0 ]; then
|
||||
debug_mesg "chzdev -d zfcp-lun ${CCW_CHAN_ID}:${FCP_WWPN}:${FCP_LUN}"
|
||||
chzdev -d zfcp-lun ${CCW_CHAN_ID}:${FCP_WWPN}:${FCP_LUN}
|
||||
elif [ "${ON_OFF}" == 1 ]; then
|
||||
debug_mesg "chzdev -e zfcp-lun ${CCW_CHAN_ID}:${FCP_WWPN}:${FCP_LUN}"
|
||||
chzdev -e zfcp-lun ${CCW_CHAN_ID}:${FCP_WWPN}:${FCP_LUN}
|
||||
else mesg "You must specify a 0 or a 1 for the online/offline attribute."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$ONLINE" ] || [ "$ONLINE" -ne "1" -a "$ONLINE" -ne "0" ]; then
|
||||
mesg "Invalid device status $ONLINE"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
_ccw_dir=${SYSFS}/bus/ccw/devices
|
||||
|
||||
_zfcp_dir="$_ccw_dir/$CCW_CHAN_ID"
|
||||
|
||||
if test ! -d "$_zfcp_dir" ; then
|
||||
mesg "No device ${CCW_CHAN_ID}"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
RULES_DIR=/etc/udev/rules.d
|
||||
RULES_FILE=51-zfcp-${CCW_CHAN_ID}.rules
|
||||
|
||||
if [ ! -f ${RULES_DIR}/${RULES_FILE} ]; then
|
||||
debug_mesg "No configuration file for adapter ${CCW_CHAN_ID}"
|
||||
fi
|
||||
|
||||
# Check whether we need to do something
|
||||
read allow_lun_scan < /sys/module/zfcp/parameters/allow_lun_scan
|
||||
if [ "$allow_lun_scan" = "Y" ] ; then
|
||||
for host in ${_zfcp_dir}/host* ; do
|
||||
[ -d $host ] || continue
|
||||
hba_num=${host##*host}
|
||||
done
|
||||
read port_type < /sys/class/fc_host/host${hba_num}/port_type
|
||||
if [ "$port_type" = "NPIV VPORT" ] ; then
|
||||
auto_lun_scan=1
|
||||
fi
|
||||
|
||||
if [ -z "${hba_num}" ] ; then
|
||||
if [ "$ONLINE" -eq "1" ]; then
|
||||
debug_mesg "FCP adapter ${CCW_CHAN_ID} not configured"
|
||||
exit 1
|
||||
else
|
||||
debug_mesg "FCP adapter ${CCH_CHAN_ID} already deconfigured"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
elif [ -d ${_zfcp_dir}/0x${FCP_WWPN}/0x${FCP_LUN} ]; then
|
||||
if [ "$ONLINE" -eq "1" ]; then
|
||||
debug_mesg "FCP disk ${FCP_WWPN}:${FCP_LUN} already configured"
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
if [ "$ONLINE" -eq "0" ]; then
|
||||
debug_mesg "FCP disk ${FCP_WWPN}:${FCP_LUN} does not exist"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$ONLINE" -eq "1" ]; then
|
||||
# Configure SCSI disk
|
||||
debug_mesg "Configuring FCP disk ${FCP_WWPN}:${FCP_LUN}"
|
||||
|
||||
# Check whether the wwpn exists
|
||||
if [ "$auto_lun_scan" = 1 ] ; then
|
||||
for rport in /sys/class/fc_remote_ports/rport-${hba_num}:* ; do
|
||||
[ -f ${rport}/port_name ] || continue
|
||||
read port_name < ${rport}/port_name
|
||||
if [ "$port_name" = "0x${FCP_WWPN}" ] ; then
|
||||
for t in ${rport}/device/target* ; do
|
||||
_targetid=${t#*target}
|
||||
done
|
||||
_zfcp_wwpn_dir=${rport}
|
||||
break;
|
||||
fi
|
||||
done
|
||||
else
|
||||
_zfcp_wwpn_dir="${_zfcp_dir}/0x${FCP_WWPN}"
|
||||
fi
|
||||
if [ ! -d "${_zfcp_wwpn_dir}" ] ; then
|
||||
mesg "WWPN ${FCP_WWPN} for adapter ${CCW_CHAN_ID} not found"
|
||||
exit 5
|
||||
fi
|
||||
# Check and configure the zfcp-lun
|
||||
if [ "$auto_lun_scan" = 1 ] ; then
|
||||
if [ -n "${_targetid}" ] ; then
|
||||
for _lun in /sys/class/scsi_device/${_targetid}:* ; do
|
||||
[ -f ${_lun}/device/fcp_lun ] || continue
|
||||
read _lunid < ${_lun}/device/fcp_lun
|
||||
if [ "${_lunid}" = "0x${FCP_LUN}" ] ; then
|
||||
_zfcp_lun_dir="${_lun}/device"
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ -z "$_zfcp_lun_dir" ] ; then
|
||||
mesg "Could not activate FCP disk ${FCP_WWPN}:${FCP_LUN}"
|
||||
exit 6
|
||||
fi
|
||||
else
|
||||
# Check whether the WWPN is activated
|
||||
if [ `cat ${_zfcp_wwpn_dir}/failed` -eq "1" ] ; then
|
||||
mesg "WWPN ${FCP_WWPN} invalid."
|
||||
exit 4
|
||||
fi
|
||||
if [ ! -d "${_zfcp_wwpn_dir}/0x${FCP_LUN}" ] ; then
|
||||
echo "0x${FCP_LUN}" > ${_zfcp_wwpn_dir}/unit_add
|
||||
/sbin/udevadm settle
|
||||
fi
|
||||
# Re-check whether the disk could be activated
|
||||
if [ ! -d "${_zfcp_wwpn_dir}/0x${FCP_LUN}" ] ; then
|
||||
mesg "Could not activate FCP disk ${FCP_WWPN}:${FCP_LUN}"
|
||||
exit 6
|
||||
fi
|
||||
# Check for failed disks
|
||||
read wwpn_status < ${_zfcp_wwpn_dir}/0x${FCP_LUN}/status
|
||||
while [ "$wwpn_status" != 0 ] ; do
|
||||
sleep 1
|
||||
read wwpn_status < ${_zfcp_wwpn_dir}/0x${FCP_LUN}/in_recovery
|
||||
[ "$wwpn_status" = 0 ] && break
|
||||
done
|
||||
read wwpn_status < ${_zfcp_wwpn_dir}/0x${FCP_LUN}/failed
|
||||
if [ "$wwpn_status" = 1 ] ; then
|
||||
debug_mesg "ERP failed on FCP disk ${FCP_WWPN}:${FCP_LUN}"
|
||||
exit 7
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# Deconfigure SCSI disk
|
||||
debug_mesg "Deconfiguring FCP disk ${FCP_WWPN}:${FCP_LUN}"
|
||||
|
||||
_zfcp_wwpn_dir="${_zfcp_dir}/0x${FCP_WWPN}"
|
||||
# Find the correspondig SCSI disk
|
||||
for host_dir in $_zfcp_dir/host*; do
|
||||
if [ -d $host_dir ] ; then
|
||||
_zfcp_scsi_host_dir=$host_dir
|
||||
break;
|
||||
fi
|
||||
done
|
||||
if [ -d "$_zfcp_scsi_host_dir" ] ; then
|
||||
# Deregister the disk from SCSI layer
|
||||
for target in $_zfcp_scsi_host_dir/rport-*/target*/* ; do
|
||||
[ "$target" != "${target##*/fc_transport}" ] && continue
|
||||
if [ -d "$target" ] && [ -d "$target/scsi_device" ] ; then
|
||||
_zfcp_scsi_id=${target##*/}
|
||||
read _zfcp_tmp_hba < ${target}/hba_id
|
||||
read _zfcp_tmp_wwpn < ${target}/wwpn
|
||||
read _zfcp_tmp_lun < ${target}/fcp_lun
|
||||
if [ "0x${FCP_LUN}" = "$_zfcp_tmp_lun" -a "0x${FCP_WWPN}" = "$_zfcp_tmp_wwpn" ] ; then
|
||||
if [ "$auto_lun_scan" = 1 ] ; then
|
||||
mesg "Could not deactivate SCSI disk ${_zfcp_scsi_id}"
|
||||
exit 7
|
||||
else
|
||||
echo 1 > $target/delete
|
||||
_zfcp_scsi_dir=$target
|
||||
fi
|
||||
break;
|
||||
fi
|
||||
fi
|
||||
done
|
||||
/sbin/udevadm settle
|
||||
else
|
||||
debug_mesg "No SCSI disk found for FCP disk ${FCP_WWPN}:${FCP_LUN}"
|
||||
fi
|
||||
|
||||
# Re-check whether the SCSI disk is gone
|
||||
num=$udev_timeout
|
||||
while [ $num -gt 0 ] ; do
|
||||
[ -d "${_zfcp_scsi_dir}" ] || break
|
||||
let num=$num-1
|
||||
sleep 1
|
||||
done
|
||||
if [ -d "${_zfcp_scsi_dir}" ]; then
|
||||
mesg "Could not deactivate SCSI disk ${_zfcp_scsi_id}"
|
||||
exit 7
|
||||
fi
|
||||
|
||||
# Wait for udev to catch up
|
||||
/sbin/udevadm settle
|
||||
|
||||
# check multipathing
|
||||
_zfcp_scsi_dev=$(multipathd -k'show paths' 2> /dev/null | sed -n "s/$_zfcp_scsi_id \(sd[a-z]*\).*/\1/p")
|
||||
[ "$_zfcp_scsi_dev" ] && multipathd -k"del path $_zfcp_scsi_dev"
|
||||
|
||||
# Deconfigure the FCP_LUN
|
||||
: ${_zfcp_wwpn_dir}
|
||||
echo "0x${FCP_LUN}" > ${_zfcp_wwpn_dir}/unit_remove
|
||||
if [ -d "${_zfcp_wwpn_dir}/0x${FCP_LUN}" ]; then
|
||||
mesg "Could not deregister FCP LUN ${FCP_LUN}"
|
||||
exit 8
|
||||
fi
|
||||
|
||||
# Find all remaining activated disks
|
||||
ZFCP_LUNS=
|
||||
for _tmp_wwpn_dir in ${_zfcp_dir}/0x*; do
|
||||
if [ -d "$_tmp_wwpn_dir" ]; then
|
||||
tmp_wwpn=$(basename $_tmp_wwpn_dir)
|
||||
# Find all luns
|
||||
for _tmp_lun_dir in ${_tmp_wwpn_dir}/0x*; do
|
||||
if [ -d "$_tmp_lun_dir" ]; then
|
||||
tmp_lun=$(basename $_tmp_lun_dir)
|
||||
tmp_port="${tmp_wwpn}:${tmp_lun}"
|
||||
ZFCP_LUNS="$ZFCP_LUNS
|
||||
$tmp_port"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# And now update the rules file
|
||||
if test -d ${RULES_DIR}; then
|
||||
# Find all WWPNs
|
||||
|
||||
read online < ${_zfcp_dir}/online;
|
||||
if [ $online -eq 0 ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for port in ${_zfcp_dir}/0x* ; do
|
||||
[ -d $port ] || continue;
|
||||
[ -w $port/unit_remove ] || continue;
|
||||
port_list="$port_list ${port##*/}"
|
||||
done
|
||||
|
||||
cat > ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
# Configure zFCP device at ${CCW_CHAN_ID}
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CCW_CHAN_ID", IMPORT{program}="collect $CCW_CHAN_ID %k $CCW_CHAN_ID zfcp"
|
||||
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="zfcp", IMPORT{program}="collect $CCW_CHAN_ID %k $CCW_CHAN_ID zfcp"
|
||||
ACTION=="add", ENV{COLLECT_$CCW_CHAN_ID}=="0", ATTR{[ccw/$CCW_CHAN_ID]online}="1"
|
||||
EOF
|
||||
for port in $port_list; do
|
||||
for lun in ${_zfcp_dir}/$port/0x* ; do
|
||||
[ -d $lun ] || continue;
|
||||
[ -r $lun/status ] || continue;
|
||||
cat >> ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
ACTION=="add", KERNEL=="rport-*", ATTR{port_name}=="$port", SUBSYSTEMS=="ccw", KERNELS=="$CCW_CHAN_ID", ATTR{[ccw/$CCW_CHAN_ID]$port/unit_add}="${lun##*/}"
|
||||
EOF
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
# EOF
|
||||
|
@ -2,185 +2,94 @@
|
||||
#
|
||||
# zfcp_host_configure
|
||||
#
|
||||
# Configures a zfcp host adapter
|
||||
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# Configures a zfcp host adapter by calling the IBM-provided chzdev command.
|
||||
# Whereas this script used to validate the parameters provided to it,
|
||||
# we now rely on chzdev to do that instead. The script is intended only
|
||||
# as a "translation layer" to provide backward compatability for older
|
||||
# scripts and tools that invoke it.
|
||||
#
|
||||
#
|
||||
# Usage:
|
||||
# zfcp_host_configure <ccwid> <online>
|
||||
#
|
||||
# ccwid = 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.
|
||||
# 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 codes
|
||||
# 1 sysfs not mounted
|
||||
# 2 invalid value for <online>
|
||||
# 3 device <ccwid> does not exist
|
||||
# 4 module zfcp could not be loaded
|
||||
# 5 adapter status could not be changed
|
||||
# 6 wwpn ports still active
|
||||
# 10 adapter active but allow_lun_scan active
|
||||
# Return codes are determined by the chzdev command.
|
||||
#
|
||||
|
||||
if [ "${DEBUG}" != "yes" ]; then
|
||||
DEBUG="no"
|
||||
fi
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
mesg () {
|
||||
echo "$@"
|
||||
}
|
||||
|
||||
debug_mesg () {
|
||||
case "$DEBUG" in
|
||||
yes) mesg "$@" ;;
|
||||
*) ;;
|
||||
case "${DEBUG}" in
|
||||
yes) mesg "$@" ;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [ $# -ne 2 ] ; then
|
||||
echo "Usage: $0 <ccwid> <online>"
|
||||
echo " ccwid = 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
|
||||
add_cio_channel() {
|
||||
echo "$* # ${DATE}" >> /boot/zipl/active_devices.txt
|
||||
}
|
||||
|
||||
remove_cio_channel() {
|
||||
[ -w /boot/zipl/active_devices.txt ] && sed -i -e "/^${1}/d" /boot/zipl/active_devices.txt
|
||||
}
|
||||
|
||||
usage(){
|
||||
echo "Usage: ${0} <ccwid> <online>"
|
||||
echo " ccwid = 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"
|
||||
echo " this is 0, but it could be non-zero"
|
||||
echo " ssss is the four digit subchannel address of the device, in"
|
||||
echo " hexidecimal, with leading zeros."
|
||||
echo " online = 0 to take the device offline"
|
||||
echo " 1 to bring the device online"
|
||||
}
|
||||
|
||||
if [ "${DEBUG}" != "yes" ]; then
|
||||
DEBUG="no"
|
||||
fi
|
||||
|
||||
# Get the mount point for sysfs
|
||||
while read MNTPT MNTDIR MNTSYS MNTTYPE; do
|
||||
if test "$MNTSYS" = "sysfs"; then
|
||||
SYSFS="$MNTDIR"
|
||||
break;
|
||||
fi
|
||||
done </proc/mounts
|
||||
DATE=$(date)
|
||||
|
||||
if [ -z "$SYSFS" ]; then
|
||||
mesg "/sysfs not present"
|
||||
exit 1
|
||||
CCW_CHAN_ID=${1}
|
||||
ON_OFF=${2}
|
||||
|
||||
if [ -z "${CCW_CHAN_ID}" ] || [ -z "${ON_OFF}" ]; then
|
||||
mesg "You didn't specify all the needed parameters."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CCW_CHAN_ID=$1
|
||||
ONLINE=$2
|
||||
MODULE=zfcp
|
||||
|
||||
if [ -z "$CCW_CHAN_ID" ] ; then
|
||||
mesg "No CCW device specified"
|
||||
exit 1
|
||||
if [ "${ON_OFF}" == 0 ]; then
|
||||
debug_mesg "chzdev -d zfcp-host ${CCW_CHAN_ID}"
|
||||
chzdev -d zfcp-host ${CCW_CHAN_ID}
|
||||
elif [ "${ON_OFF}" == 1 ]; then
|
||||
debug_mesg "chzdev -e zfcp-host ${CCW_CHAN_ID}"
|
||||
chzdev -e zfcp-host ${CCW_CHAN_ID}
|
||||
else mesg "You must specify a 0 or a 1 for the online/offline attribute."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$ONLINE" ] || [ "$ONLINE" != "1" -a "$ONLINE" != "0" ]; then
|
||||
mesg "Invalid device status $ONLINE"
|
||||
exit 2
|
||||
RC=${?}
|
||||
if [ ${RC} -ne 0 ]; then
|
||||
exit ${RC}
|
||||
fi
|
||||
|
||||
_ccw_dir=${SYSFS}/bus/ccw/devices
|
||||
|
||||
_zfcp_dir="$_ccw_dir/$CCW_CHAN_ID"
|
||||
|
||||
if test ! -d "$_zfcp_dir" ; then
|
||||
mesg "No device ${CCW_CHAN_ID}"
|
||||
exit 3
|
||||
if [ ${ON_OFF} == 1 ]; then
|
||||
add_cio_channel "${CCW_CHAN_ID}"
|
||||
else remove_cio_channel "${CCW_CHAN_ID}"
|
||||
fi
|
||||
|
||||
# Check whether we need to load the zfcp module
|
||||
if test ! -d "${SYSFS}/bus/ccw/drivers/zfcp"; then
|
||||
modprobe ${MODULE}
|
||||
|
||||
# Re-check whether module loading has succeeded
|
||||
if test ! -d "${SYSFS}/bus/ccw/drivers/zfcp"; then
|
||||
mesg "Could not load module ${MODULE}"
|
||||
exit 4
|
||||
fi
|
||||
fi
|
||||
|
||||
RULES_DIR=/etc/udev/rules.d
|
||||
RULES_FILE=51-zfcp-${CCW_CHAN_ID}.rules
|
||||
ALREADY_ONLINE=0
|
||||
|
||||
# Check whether we need to do something
|
||||
_zfcp_dev_status=$(cat $_zfcp_dir/online)
|
||||
if [ "$_zfcp_dev_status" -eq "$ONLINE" ]; then
|
||||
debug_mesg "zFCP adapter ${CCW_CHAN_ID} already in status ${ONLINE}"
|
||||
ALREADY_ONLINE=1
|
||||
fi
|
||||
|
||||
debug_mesg "Configuring device ${CCW_CHAN_ID}"
|
||||
|
||||
if [ -f ${RULES_DIR}/${RULES_FILE} ]; then
|
||||
rm -f ${RULES_DIR}/${RULES_FILE}
|
||||
fi
|
||||
|
||||
|
||||
if [ "$ONLINE" -eq "1" ]; then
|
||||
if [ "${ALREADY_ONLINE}" -eq "0" ]; then
|
||||
# Activate the device
|
||||
echo "$ONLINE" > $_zfcp_dir/online
|
||||
|
||||
# Now wait for the adapter to initialize
|
||||
/sbin/udevadm settle
|
||||
fi
|
||||
|
||||
for loop in 1 2 3 4 5 ; do
|
||||
read status < /sys/bus/ccw/devices/$CCW_CHAN_ID/status
|
||||
(( $status & 0x10000000 )) && break;
|
||||
done
|
||||
read wwpn_status < /sys/bus/ccw/devices/$CCW_CHAN_ID/status
|
||||
if !(( $wwpn_status & 0x10000000 )) ; then
|
||||
echo 0 > /sys/bus/ccw/devices/$CCW_CHAN_ID/online
|
||||
mesg "Could not activate adapter, status $wwpn_status"
|
||||
exit 5
|
||||
fi
|
||||
|
||||
# Write the configuration file
|
||||
if test -d ${RULES_DIR}; then
|
||||
cat > ${RULES_DIR}/${RULES_FILE} <<EOF
|
||||
# Configuration for the zfcp adapter at CCW ID ${CCW_CHAN_ID}
|
||||
ACTION=="add", SUBSYSTEM=="ccw", KERNEL=="$CCW_CHAN_ID", IMPORT{program}="collect $CCW_CHAN_ID %k $CCW_CHAN_ID zfcp"
|
||||
ACTION=="add", SUBSYSTEM=="drivers", KERNEL=="zfcp", IMPORT{program}="collect $CCW_CHAN_ID %k $CCW_CHAN_ID zfcp"
|
||||
ACTION=="add", ENV{COLLECT_$CCW_CHAN_ID}=="0", ATTR{[ccw/$CCW_CHAN_ID]online}="1"
|
||||
EOF
|
||||
fi
|
||||
add_channel_for_cio "${CCW_CHAN_ID}"
|
||||
# Check whether we need to do something
|
||||
read allow_lun_scan < /sys/module/zfcp/parameters/allow_lun_scan
|
||||
if [ "$allow_lun_scan" = "Y" ] ; then
|
||||
for host in ${_zfcp_dir}/host* ; do
|
||||
[ -d $host ] || continue
|
||||
hba_num=${host##*host}
|
||||
done
|
||||
# Automatic LUN scan is only possible on NPIV ports
|
||||
read port_type < /sys/class/fc_host/host${hba_num}/port_type
|
||||
if [ "$port_type" = "NPIV VPORT" ] ; then
|
||||
exit 10;
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "0" > ${_zfcp_dir}/online
|
||||
# Re-read to check whether we have succeeded
|
||||
_ccw_dev_status=$(cat $_zfcp_dir/online)
|
||||
if [ "$_ccw_dev_status" -ne "$ONLINE" ]; then
|
||||
mesg "Could not change status of device ${CCW_CHAN_ID} to $ONLINE"
|
||||
exit 5
|
||||
fi
|
||||
echo "${CCW_CHAN_ID}" > /sys/bus/ccw/drivers/zfcp/unbind
|
||||
echo "${CCW_CHAN_ID}" > /sys/bus/ccw/drivers/zfcp/bind
|
||||
remove_channel_for_cio "${CCW_CHAN_ID}"
|
||||
|
||||
debug_mesg "zFCP adapter at ${CCW_CHAN_ID} deactivated"
|
||||
fi
|
||||
|
||||
# EOF
|
||||
|
Loading…
Reference in New Issue
Block a user