From: "Guo, Min" <min.guo@intel.com>
To: linux-hotplug@vger.kernel.org
Subject: RE: About test suites for linux hot plug
Date: Thu, 26 Dec 2002 07:32:32 +0000 [thread overview]
Message-ID: <marc-linux-hotplug-104088836327564@msgid-missing> (raw)
In-Reply-To: <marc-linux-hotplug-103838709921894@msgid-missing>
Hi,
I enhanced my test suites, added the following features
1. Check the io ports and io mem for cPCI devices,including two procedures,
one is plug/remove ,the other is remove/plug. it needs to manual operation
2. check the io ports and io mem for PCI hotplug devices,including two
procedures,
one is plug/remove ,the other is remove/plug.it can work automatically.
I had verified the ZT5550 cpci and Compaq hotplug PCI net devices with
the test cases.
----------------------------------------------------------------------------
---------------------------------------
#!/bin/sh
HOTSWAP_TEST_VERSION="0.1"
PCI_TOOLS="lspci"
HOT_SWAP_KEY="06"
COMPACTPCI_HOTPLUG_DEVICE=""
DRIVERS_NUMBER=`$PCI_TOOLS|awk '{print $1}'`
HOT_PLUG_SUPPORTúlse
HARD_PASSúlse
value=""
link="33"
PCI_FILE="pci_file"
cPCI_DEVICE=""
CPCI_NONE=0
CPCI_PLUG=1
CPCI_REMOVE=2
COMPAQ_PCI_HOTPLUG_DIR="/pcihpfs"
#function capfind is used to find the capbilities of PCI devices and see
whether
#there are some devices support the defined capbilities
capfind()
{
link=$1
link_tmp=0x$link
link_tmp=`echo $((link_tmp))`
startadd=`expr $link_tmp / 16 + 2`
mod $link
offset=`echo $?`
offset1=`expr $offset + 2`
offset=`expr $offset + 3`
link_offset=`echo $((offset))`
value_offset=`echo $((offset1))`
value=`cat $PCI_FILE|head -n $startadd|tail -n 1|cut -d ' ' -f
$value_offset`
link=`cat $PCI_FILE|head -n $startadd|tail -n 1|cut -d ' ' -f
$link_offset`
}
#The function to give out the mod number
mod()
{
number_tmp=$1
number_tmp=0x$number_tmp
number=`echo $((number_tmp))`
while [ "$number" -ge "16" ];do
number=`expr $number - 16`
done
return $number
}
#check which device have compact PCI hot_swap function
#if have,give out the the results.
check_hotplug_cap()
{
i=0
echo "" > cpci_hotswap
for driver in $DRIVERS_NUMBER
do
#read the capbility number and verify whether the system has hotplug
#controller
#confighead=`lspci -s $driver -xxx|grep -v PCI'`
lspci -s $driver -xxx > $PCI_FILE
#find the frist capbility link of configure header
while [ "$link" != "00" ]
do
capfind $link
if [ "$value" = "$HOT_SWAP_KEY" ];then
HOT_PLUG_SUPPORT=true
fi
if [ "$HOT_PLUG_SUPPORT" = "true" ];then
HARD_PASS=true
COMPACT_HOTPLUG_DEVICE=$driver
echo $COMPACT_HOTPLUG_DEVICE >> cpci_hotswap
echo "The hardware supports cPCI HotSwap
function"
descript=`lspci -s $driver`
echo "The Compact PCI Hot Swap device is" \
$descript
i=`expr $i + 1`
fi
done
link="33"
HOT_PLUG_SUPPORT="false"
done
if [ "$HARD_PASS" = "false" ];then
echo "Hardware does not support cPCI HotSwap function"
return 1
else
return 0
fi
}
#Check whether the device still exist after we remove the compactPCI hot
swap de
#device
check_after_remove()
{
cPCI_DEVICES=`cat cpci_hotswap`
if [ "$cPCI_DEVICES" = "" ];then
echo "There are no devices support cPCI hot plug function"
exit 1
fi
for device in $cPCI_DEVICES
do
device=`lspci|grep "$device"|awk -F ":" '{print $3}'`
if [ $? -eq 0 ];then
echo $device "still be pluged or can not be removed
successfully"
else
echo $device "has been removed successfully"
return 1
fi
done
return 0
}
check_resource()
{
cat /proc/ioports > /tmp/cpci_ioport_$1
cat /proc/iomem > /tmp/cpci_iomem_$1
}
cpci_check_remove_plug()
{
check_hotplug_cap
CPCI_CAP=$?
Mark=`cat /tmp/mark`
if [ ! -f /tmp/entry ];then
echo 0 > /tmp/entry
fi
entry=`cat /tmp/entry`
if [ $CPCI_CAP -eq 0 -a $entry -ne $CPCI_PLUG ];then
check_resource plug
Mark=`expr $Mark + 1`
echo $Mark > /tmp/mark
echo $CPCI_PLUG > /tmp/entry
fi
entry=`cat /tmp/entry`
if [ $CPCI_CAP -ne 0 -a $entry -ne $CPCI_REMOVE ];then
check_resource remove
Mark=`expr $Mark + 1`
echo $Mark > /tmp/mark
echo $CPCI_REMOVE > /tmp/entry
fi
Mark=`cat /tmp/mark`
if [ $CPCI_CAP -ne 0 -a $Mark -lt 2 ];then
echo "Pls plug your devices manually"
echo "............................"
exit 1
fi
if [ $CPCI_CAP -eq 0 -a $Mark -lt 2 ];then
echo "PLs remove your cpci devices manually"
echo "....................................."
exit 0
fi
Mark=`cat /tmp/mark`
if [ $Mark -eq 2 ];then
cpci_information remove_plug
echo $CPCI_NONE > /tmp/mark
echo $CPCI_NONE > /tmp/entry
rm -f /tmp/cpci*
rm -f /tmp/diff*
fi
}
cpci_information()
{
if [ $1 = "remove_plug" ];then
flag="allocate"
else
flag="deallocate"
fi
diff /tmp/cpci_ioport_remove /tmp/cpci_ioport_plug|grep ">" >
/tmp/diff_cpci_ioports
diff /tmp/cpci_iomem_remove /tmp/cpci_iomem_plug|grep ">" >
/tmp/diff_cpci_iomem
ioport=`cat /tmp/diff_cpci_ioports|awk '{print $2}'`
io_name=`cat /tmp/diff_cpci_ioports|cut -d : -f 2|head -n 1`
mem=`cat /tmp/diff_cpci_iomem|awk '{print $2}'`
mem_name=`cat /tmp/diff_cpci_iomem|cut -d : -f 2|head -n 1`
if [ -n "$ioport" -o -n "$mem" ];then
if [ -n "$ioport" ];then
echo "system $flag the io port address" $ioport for
"device" $io_name
fi
if [ -n "$mem" ];then
echo "System $flag the io mem address" $mem for
"device" $mem_name
fi
else
echo "System deallocate error"
fi
}
cpci_check_plug_remove()
{
check_hotplug_cap
CPCI_CAP=$?
Mark=`cat /tmp/mark`
if [ ! -f /tmp/entry ];then
echo 0 > /tmp/entry
fi
entry=`cat /tmp/entry`
if [ $CPCI_CAP -eq 0 -a $entry -ne $CPCI_PLUG ];then
check_resource plug
Mark=`expr $Mark + 1`
echo $Mark > /tmp/mark
echo $CPCI_PLUG > /tmp/entry
fi
if [ $CPCI_CAP -ne 0 -a $entry -ne $CPCI_REMOVE ];then
check_resource remove
Mark=`expr $Mark + 1`
echo $Mark > /tmp/mark
echo $CPCI_REMOVE > /tmp/entry
fi
Mark=`cat /tmp/mark`
if [ $CPCI_CAP -ne 0 -a $Mark -lt 2 ];then
echo "Pls plug your devices manually"
echo "............................"
exit 1
fi
if [ $CPCI_CAP -eq 0 -a $Mark -lt 2 ];then
echo "PLs remove your cpci devices manually"
echo "....................................."
exit 0
fi
Mark=`cat /tmp/mark`
if [ $Mark -eq 2 ];then
cpci_information plug_remove
echo $CPCI_NONE > /tmp/mark
echo $CPCI_NONE > /tmp/entry
rm -f /tmp/cpci*
rm -f /tmp/diff*
fi
}
notice()
{
echo "You should remove the Hot swap devices manually and check"
echo "whether the device is still there"
}
#the function is used to check the NET hot swap devices
debug_on()
{
cp -r /sbin/hotplug /sbin/hotplug-bk
sed -e 's/#DEBUG/DEBUG/' /sbin/hotplug-bk > /sbin/hotplug
dmesg -c
}
#Auto Enable the hot plug
pci_plug()
{
echo 1 > power
}
# Auto Disable the Hot plug
pci_remove()
{
echo 0 > power
}
change_sub_dir()
{
echo "If only some of your hotplug slots have been inserted "
echo "devices, so you should set the SUB_DIR by yourselves"
SUB_DIR="1"
}
check_pci_hardware()
{
HARD_PASS_1=true
#check whether module has been inserted
if [ -d $COMPAQ_PCI_HOTPLUG_DIR ];then
cd $COMPAQ_PCI_HOTPLUG_DIR
SUB_DIR=`ls`
change_sub_dir
if [ "$SUB_DIR" = "" ];then
echo "Hot Plug driver has not been installed"
echo "Or there are no hot plug devices"
exit 1
fi
else
exit 1
fi
for dir in $SUB_DIR
do
cd $dir
pci_remove
cd ..
done
for dir in $SUB_DIR
do
cd $dir
pci_plug
value=`cat power`
if [ $value -ne "1" ];then
HARD_PASS_1úlse
echo $HARD_PASS_1
echo "We can not Plug the devices
automatically,so check your hardware"
echo "Or check whether the hotplug slot have
been filled"
fi
cd ..
done
if [ "$HARD_PASS_1" = "true" ];then
echo "PASS1: HardWare Check"
fi
}
check_pci_hotplug_net_device()
{
SOFT_PASSúlse
#check whether module has been inserted
if [ -d $COMPAQ_PCI_HOTPLUG_DIR ];then
cd $COMPAQ_PCI_HOTPLUG_DIR
SUB_DIR=`ls`
change_sub_dir
if [ "$SUB_DIR" = "" ];then
exit 1
fi
else
exit 1
fi
for dir in $SUB_DIR
do
cd $dir
pci_remove
cd ..
done
debug_on > /dev/null 2>&1
# Check whether the network inteface can be booted correctly.
ethnum=`ifconfig|grep eth|wc -l`
for dir in $SUB_DIR
do
SOFT_PASSúlse
cd $dir
pci_plug
ethnum=`echo $((ethnum))`
ifconfig|grep eth"$ethnum" >/dev/null 2>&1
if [ "$?" -eq 0 ];then
echo "The pci hot plug device can been
booted automatically"
SOFT_PASS=true
else
ifup eth"$ethnum" >/dev/null 2>&1
if [ "$?" -eq 0 ];then
echo "The pci hotplug net device can
been booted correctly"
SOFT_PASS=true
else
SOFT_PASSúlse
echo "please check your network
configuration or hotplug device driver"
echo "the message in
/var/log/messages will help you locate your error"
fi
fi
cd ..
ethnum=`expr $ethnum + 1`
done
if [ $SOFT_PASS = "true" ];then
echo "PASS2: The software check"
fi
}
check_file()
{
awk '{
name=$4
add=$2
print addrtype
if (name != "" && add !="")
{
printf("System allocate name %s addr_type %s
%s\n",name,addrtype,add)
}else
{
printf("System allocation error %s",name)
}
}
' $1
}
check_mem_info()
{
#set -x
#check whether module has been inserted
if [ -d $COMPAQ_PCI_HOTPLUG_DIR ];then
cd $COMPAQ_PCI_HOTPLUG_DIR
SUB_DIR=`ls`
change_sub_dir
if [ "$SUB_DIR" = "" ];then
exit 1
fi
else
exit 1
fi
echo "Checking the Mem information procedure remove/plug"
for dir in $SUB_DIR
do
cd $dir
pci_remove
cat /proc/iomem > /tmp/before_mm_$dir
pci_plug
cat /proc/iomem > /tmp/after_mm_$dir
diff /tmp/before_mm_$dir /tmp/after_mm_$dir >
/tmp/diff_mm
check_file /tmp/diff_mm
cd ..
done
echo "Checking the Mem information procedure plug/remove"
for dir in $SUB_DIR
do
cd $dir
pci_remove
pci_plug
cat /proc/iomem > /tmp/before_mm_$dir
pci_remove
cat /proc/iomem > /tmp/after_dmm_$dir
diff /tmp/before_mm_$dir /tmp/after_mm_$dir >
/tmp/diff_mm
check_file /tmp/diff_mm
cd ..
done
}
check_io_mem_info()
{
#check whether module has been inserted
if [ -d $COMPAQ_PCI_HOTPLUG_DIR ];then
cd $COMPAQ_PCI_HOTPLUG_DIR
SUB_DIR=`ls`
change_sub_dir
if [ "$SUB_DIR" = "" ];then
exit 1
fi
else
exit 1
fi
echo "Checking the IO information procedure remove/plug"
for dir in $SUB_DIR
do
cd $dir
pci_remove
cat /proc/ioports > /tmp/before_ioports_$dir
cat /proc/iomem > /tmp/before_mm_$dir
pci_plug
cat /proc/ioports > /tmp/after_ioports_$dir
cat /proc/iomem > /tmp/after_mm_$dir
diff /tmp/before_mm_$dir /tmp/after_mm_$dir|grep ">"
> /tmp/diff_mm
diff /tmp/before_ioports_$dir
/tmp/after_ioports_$dir|grep ">" > /tmp/diff_ioports
ioport=`cat /tmp/diff_ioports|awk '{print $2}'`
io_name=`cat /tmp/diff_ioports|awk '{print $4}'|head
-n 1`
mem=`cat /tmp/diff_mm|awk '{print $2}'`
mem_name=`cat /tmp/diff_mm|awk '{print $4}'|head -n
1`
if [ -n "$ioport" -o -n "$mem" ];then
if [ -n "$ioport" ];then
echo "system allocate the io
address" $ioport for "device" $io_name
fi
if [ -n "$mem" ];then
echo "System allocate the mem
address" $mem for "device" $mem_name
fi
else
echo "System allocate error"
fi
cd ..
done
for dir in $SUB_DIR
do
cd $dir
pci_remove
cd ..
done
echo "Checking the IO information procedure plug/remove"
for dir in $SUB_DIR
do
cd $dir
pci_plug
cat /proc/ioports > /tmp/before_ioports_$dir
cat /proc/iomem > /tmp/before_mm_$dir
pci_remove
cat /proc/ioports > /tmp/after_ioports_$dir
cat /proc/iomem > /tmp/after_mm_$dir
diff /tmp/before_mm_$dir /tmp/after_mm_$dir|grep "<"
> /tmp/diff_mm
diff /tmp/before_ioports_$dir
/tmp/after_ioports_$dir|grep "<" > /tmp/diff_ioports
ioport=`cat /tmp/diff_ioports|awk '{print $2}'`
io_name=`cat /tmp/diff_ioports|awk '{print $4}'|head
-n 1`
mem=`cat /tmp/diff_mm|awk '{print $2}'`
nem_name=`cat /tmp/diff_mm|awk '{print $4}'|head -n
1`
if [ -n "$ioport" -o -n "$mem" ];then
if [ -n "$ioport" ];then
echo "system deallocate the io
address" $ioport for "device" $io_name
fi
if [ -n "$mem" ];then
echo "System deallocate the mem
address" $mem for "device" $mem_name
fi
else
echo "System deallocate error"
fi
cd ..
done
}
hotplug_check()
{
if [ $# -gt 0 ];then
case "$1" in
-l)
check_hotplug_cap
exit 0
;;
-c)
check_after_remove
exit 0
;;
-n)
check_pci_hotplug_net_device
;;
-h)
check_pci_hardware
;;
-i)
check_io_mem_info
;;
*)
usage
;;
esac
fi
}
usage()
{
cat << EOF
Usage: hotplug_test [options]
options:
--list|-l)
list the devices that support CompactPCI
hotpwap,only user for cPCI platform
--platform|-p=cPCI|PCI_NET|PCI_SCSI)
platform type (cPCI|PCI_NET|PCI_SCSI), it will check
whether the devices can
be plug and removed correctly, only check basic
hardware information.
cPCI means CompactPCI
PCI_NET means PCI hotplug net devices
PCI_SCSI means PCI hotplug SCSI devices
--checkiomem|-c=PCI|cPCI_RP|cPCI_RP)
Check io information before and after remove the hot
plug devices(PCI|cPCI_RP|cPCI_RP)
R means Remove ,P means Plug
PCI means common PCI hot plug devices
cPCI_RP means frist Remove then Plug
cPCI_PR means frist Plug then Remove
--help|-h)
help and usage
--version|-v)
Test suites version
device:
device address
EOF
exit $1
}
if [ $# -eq 0 ];then
usage
exit
fi
if [ ! -f /tmp/mark ];then
touch /tmp/mark
echo $CPCI_NONE > /tmp/mark
fi
for option
do
case "$option" in
-*=*)
optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'`
option=`echo "$option"|sed 's/=.*$//'`
;;
*) optarg='' ;;
esac
case "$option" in
--help|-h)
echo "Usage: $usage"
exit 0
;;
--version|-v)
echo "version is" $HOTSWAP_TEST_VERSION
exit 0
;;
--platform|-p)
case "$optarg" in
cPCI)
hotplug_check -c
;;
PCI_NET)
hotplug_check -h
hotplug_check -n
;;
*)
usage
exit 1
;;
esac
;;
--checkiomem|-c)
case "$optarg" in
PCI)
hotplug_check -i
;;
cPCI_RP)
cpci_check_remove_plug
;;
cPCI_PR)
cpci_check_plug_remove
;;
*)
usage
exit 1
;;
esac
;;
--list|-l)
echo "only echo the Devices support cPCI hot swap function"
hotplug_check -l
exit 1
;;
*)
usage
exit 1
;;
esac
done
________________________________________________________________
-----Original Message-----
From: Scott Murray [mailto:scottm@somanetworks.com]
Sent: Saturday, November 30, 2002 5:25 AM
To: Guo, Min
Cc: Linux-hotplug-devel@lists.sourceforge.net
Subject: RE: About test suites for linux hot plug
On Thu, 28 Nov 2002, Guo, Min wrote:
> Here is my initial test suite for cPCI (ZT5084 platform) and Compaq with
> e100 and e1000 hotplug network devices,
> for the other hot plug device and features, I will give out the test
suites
> later.
Your testcase seems reasonable, but having the PCI device appear/disappear
is IMO the trivial part of PCI hotplug. The vast majority of the problems
I encountered while writing the cPCI drivers involved PCI resources. Most
of my manual testing revolves around checking the contents of /proc/iomem
and /proc/ioports before and after inserts and removes, as well as looking
at the output of "lspci -vvv". With a fixed set of hardware, it may be
possible to come up with testcases for resource allocation, but the general
case is probably difficult to automate.
Something else to be aware of is that eventually I plan to support
hardware that does not expose HS_CSR through the PCI extended capabilities.
It looks like your testcase as it stands now will break if run in a setup
that had such hardware.
Scott
PS: Are you working with Harold Yang? He's also at Intel but seems to be
having troubles using cPCI hotplug on his ZT5084 system.
--
Scott Murray
SOMA Networks, Inc.
Toronto, Ontario
e-mail: scottm@somanetworks.com
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
prev parent reply other threads:[~2002-12-26 7:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-27 8:44 About test suites for linux hot plug Guo, Min
2002-11-27 16:32 ` Greg KH
2002-11-27 19:38 ` David Brownell
2002-11-28 12:52 ` Guo, Min
2002-11-29 21:24 ` Scott Murray
2002-12-02 0:59 ` Guo, Min
2002-12-26 7:32 ` Guo, Min [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-linux-hotplug-104088836327564@msgid-missing \
--to=min.guo@intel.com \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).