From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Guo, Min" Date: Thu, 26 Dec 2002 07:32:32 +0000 Subject: RE: About test suites for linux hot plug Message-Id: List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: linux-hotplug@vger.kernel.org Hi, I enhanced my test suites, added the following features 1. Check the io ports and io mem for cPCI devices,including two procedures,= =20 one is plug/remove ,the other is remove/plug. it needs to manual operation =09 2. check the io ports and io mem for PCI hotplug devices,including two procedures,=20 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.=09 ---------------------------------------------------------------------------- --------------------------------------- #!/bin/sh HOTSWAP_TEST_VERSION=3D"0.1" PCI_TOOLS=3D"lspci" HOT_SWAP_KEY=3D"06" COMPACTPCI_HOTPLUG_DEVICE=3D"" DRIVERS_NUMBER=3D`$PCI_TOOLS|awk '{print $1}'` HOT_PLUG_SUPPORT=FAlse HARD_PASS=FAlse value=3D"" link=3D"33" PCI_FILE=3D"pci_file" cPCI_DEVICE=3D"" CPCI_NONE=3D0 CPCI_PLUG=3D1 CPCI_REMOVE=3D2 COMPAQ_PCI_HOTPLUG_DIR=3D"/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=3D$1 link_tmp=3D0x$link link_tmp=3D`echo $((link_tmp))` startadd=3D`expr $link_tmp / 16 + 2` mod $link offset=3D`echo $?` offset1=3D`expr $offset + 2` offset=3D`expr $offset + 3` link_offset=3D`echo $((offset))` value_offset=3D`echo $((offset1))` =09 value=3D`cat $PCI_FILE|head -n $startadd|tail -n 1|cut -d ' ' -f $value_offset` link=3D`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=3D$1 number_tmp=3D0x$number_tmp number=3D`echo $((number_tmp))` while [ "$number" -ge "16" ];do number=3D`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=3D0 echo "" > cpci_hotswap for driver in $DRIVERS_NUMBER do #read the capbility number and verify whether the system has hotplug #controller #confighead=3D`lspci -s $driver -xxx|grep -v PCI'` lspci -s $driver -xxx > $PCI_FILE #find the frist capbility link of configure header while [ "$link" !=3D "00" ] do capfind $link=20 if [ "$value" =3D "$HOT_SWAP_KEY" ];then HOT_PLUG_SUPPORT=3Dtrue fi if [ "$HOT_PLUG_SUPPORT" =3D "true" ];then HARD_PASS=3Dtrue COMPACT_HOTPLUG_DEVICE=3D$driver echo $COMPACT_HOTPLUG_DEVICE >> cpci_hotswap echo "The hardware supports cPCI HotSwap function" descript=3D`lspci -s $driver` echo "The Compact PCI Hot Swap device is" \ $descript i=3D`expr $i + 1` fi done link=3D"33" HOT_PLUG_SUPPORT=3D"false" done if [ "$HARD_PASS" =3D "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=3D`cat cpci_hotswap` if [ "$cPCI_DEVICES" =3D "" ];then echo "There are no devices support cPCI hot plug function" exit 1 fi for device in $cPCI_DEVICES=20 do device=3D`lspci|grep "$device"|awk -F ":" '{print $3}'` if [ $? -eq 0 ];then echo $device "still be pluged or can not be removed successfully"=20 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=3D$? Mark=3D`cat /tmp/mark` if [ ! -f /tmp/entry ];then echo 0 > /tmp/entry fi entry=3D`cat /tmp/entry` if [ $CPCI_CAP -eq 0 -a $entry -ne $CPCI_PLUG ];then check_resource plug Mark=3D`expr $Mark + 1` echo $Mark > /tmp/mark echo $CPCI_PLUG > /tmp/entry fi entry=3D`cat /tmp/entry` if [ $CPCI_CAP -ne 0 -a $entry -ne $CPCI_REMOVE ];then check_resource remove Mark=3D`expr $Mark + 1` echo $Mark > /tmp/mark echo $CPCI_REMOVE > /tmp/entry fi Mark=3D`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=3D`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 =09 } cpci_information() {=09 if [ $1 =3D "remove_plug" ];then flag=3D"allocate" else flag=3D"deallocate" fi=09 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=3D`cat /tmp/diff_cpci_ioports|awk '{print $2}'` io_name=3D`cat /tmp/diff_cpci_ioports|cut -d : -f 2|head -n 1` mem=3D`cat /tmp/diff_cpci_iomem|awk '{print $2}'` mem_name=3D`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=3D$? Mark=3D`cat /tmp/mark` if [ ! -f /tmp/entry ];then echo 0 > /tmp/entry fi entry=3D`cat /tmp/entry` if [ $CPCI_CAP -eq 0 -a $entry -ne $CPCI_PLUG ];then check_resource plug Mark=3D`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=3D`expr $Mark + 1` echo $Mark > /tmp/mark echo $CPCI_REMOVE > /tmp/entry fi Mark=3D`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=3D`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 =09 } notice() { echo "You should remove the Hot swap devices manually and check"=20 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=20 } 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=3D"1" } check_pci_hardware() { =09 HARD_PASS_1=3Dtrue #check whether module has been inserted if [ -d $COMPAQ_PCI_HOTPLUG_DIR ];then cd $COMPAQ_PCI_HOTPLUG_DIR SUB_DIR=3D`ls` change_sub_dir if [ "$SUB_DIR" =3D "" ];then echo "Hot Plug driver has not been installed" echo "Or there are no hot plug devices" exit 1 fi else exit 1 fi =09 for dir in $SUB_DIR do cd $dir pci_remove=20 cd .. done for dir in $SUB_DIR do cd $dir pci_plug value=3D`cat power` if [ $value -ne "1" ];then HARD_PASS_1=FAlse 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" =3D "true" ];then echo "PASS1: HardWare Check" fi =09 } check_pci_hotplug_net_device() { SOFT_PASS=FAlse #check whether module has been inserted if [ -d $COMPAQ_PCI_HOTPLUG_DIR ];then cd $COMPAQ_PCI_HOTPLUG_DIR SUB_DIR=3D`ls` change_sub_dir if [ "$SUB_DIR" =3D "" ];then exit 1 fi else exit 1 fi =09 for dir in $SUB_DIR do cd $dir pci_remove=20 cd .. done debug_on > /dev/null 2>&1 # Check whether the network inteface can be booted correctly. ethnum=3D`ifconfig|grep eth|wc -l` for dir in $SUB_DIR do SOFT_PASS=FAlse cd $dir pci_plug ethnum=3D`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=3Dtrue else ifup eth"$ethnum" >/dev/null 2>&1 if [ "$?" -eq 0 ];then echo "The pci hotplug net device can been booted correctly" SOFT_PASS=3Dtrue else SOFT_PASS=FAlse 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 =09 cd .. ethnum=3D`expr $ethnum + 1` done if [ $SOFT_PASS =3D "true" ];then echo "PASS2: The software check" fi } check_file() { awk '{ name=3D$4 add=3D$2 print addrtype if (name !=3D "" && add !=3D"") { 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=3D`ls` change_sub_dir if [ "$SUB_DIR" =3D "" ];then exit 1 fi else exit 1 fi echo "Checking the Mem information procedure remove/plug"=09 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 =09 echo "Checking the Mem information procedure plug/remove"=09 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=3D`ls` change_sub_dir if [ "$SUB_DIR" =3D "" ];then exit 1 fi else exit 1 fi =09 echo "Checking the IO information procedure remove/plug"=09 for dir in $SUB_DIR do cd $dir pci_remove=20 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=3D`cat /tmp/diff_ioports|awk '{print $2}'` io_name=3D`cat /tmp/diff_ioports|awk '{print $4}'|head -n 1` mem=3D`cat /tmp/diff_mm|awk '{print $2}'` mem_name=3D`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=20 fi if [ -n "$mem" ];then echo "System allocate the mem address" $mem for "device" $mem_name fi else echo "System allocate error" =20 fi cd .. done for dir in $SUB_DIR do cd $dir pci_remove cd .. done=20 =09 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=3D`cat /tmp/diff_ioports|awk '{print $2}'` io_name=3D`cat /tmp/diff_ioports|awk '{print $4}'|h= ead -n 1` mem=3D`cat /tmp/diff_mm|awk '{print $2}'` nem_name=3D`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=20 exit 0 ;; -n) check_pci_hotplug_net_device ;; -h) check_pci_hardware ;;=09 -i) check_io_mem_info=20 ;; *) usage ;; esac fi }=20 usage() { cat << EOF Usage: hotplug_test [options]=20 options: --list|-l) list the devices that support CompactPCI hotpwap,only user for cPCI platform --platform|-p=3DcPCI|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=3DPCI|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=20 --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 -*=3D*)=20 optarg=3D`echo "$option" | sed 's/[-_a-zA-Z0-9]*=3D//'` option=3D`echo "$option"|sed 's/=3D.*$//'` ;; *) optarg=3D'' ;; 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=20 ;;=09 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=20 ;; *) usage exit 1 ;; esac ;;=09 --list|-l) echo "only echo the Devices support cPCI hot swap function" hotplug_check -l exit 1 ;;=09 *) 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.=20 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=20 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=20 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=20 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.=20 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. --=20 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