diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/device_info.sh | 81 | ||||
-rwxr-xr-x | tests/new_device.sh | 6 | ||||
-rwxr-xr-x | tests/reload.sh | 25 |
3 files changed, 106 insertions, 6 deletions
diff --git a/tests/device_info.sh b/tests/device_info.sh new file mode 100755 index 0000000..21e59db --- /dev/null +++ b/tests/device_info.sh @@ -0,0 +1,81 @@ +#! /bin/bash + +BAR=0 + +function pci { + PCILIB_PATH=`pwd`/.. + LD_LIBRARY_PATH="$PCILIB_PATH/pcilib" $PCILIB_PATH/pcitool/pci $* +} + + +function read_cfg { + pci -a config -r 0x$1 | awk '{ print $2; }' | sed -e 's/\s*//g' -e '/^\s*$/d' +} + +function parse_config { + info=0x`pci -b $BAR -r 0 | awk '{ print $2; }' | sed -e 's/\s*//g' -e '/^\s*$/d'` + model=`printf "%X" $((info>>24))` + if [ $model -eq 14 ]; then + model="Xilinx Virtex-6" + else + model="Xilinx $model" + fi + version=$(((info >> 8) & 0xFF)) + data_width=$((16 * (2 ** ((info >> 16) & 0xF)))) + + echo "$model, build $version, $data_width bits" + + + next=`read_cfg 34 | cut -c 7-8` +# next=`printf "%u" $next` + + while [ $((0x$next)) -ne 0 ]; do + cap=`read_cfg $next` + capid=`echo $cap | cut -c 7-8` + if [ $capid -eq 10 ]; then + addr=`printf "%X" $((0x$next + 4))` + device_capabilities=`read_cfg $addr` + + addr=`printf "%X" $((0x$next + 8))` + device_control=`read_cfg $addr` + + addr=`printf "%X" $((0x$next + 12))` + pcie_link1=`read_cfg $addr` + addr=`printf "%X" $((0x$next + 16))` + pcie_link2=`read_cfg $addr` + + link_speed=$((((0x$pcie_link2 & 0xF0000) >> 16))) + link_width=$((((0x$pcie_link2 & 0x3F00000) >> 20))) + + dev_link_speed=$((((0x$pcie_link1 & 0xF)))) + dev_link_width=$((((0x$pcie_link1 & 0x3F0) >> 4))) + + max_payload=$(((1 << ((0x$device_capabilities & 0x07) + 7)))) + dev_payload=$(((1 << (((0x$device_capabilities >> 5) & 0x07) + 7)))) + fi + next=`echo $cap | cut -c 5-6` + done + + echo "Link: PCIe gen$link_speed x$link_width" + if [ $link_speed -ne $dev_link_speed -o $link_width -ne $dev_link_width ]; then + echo " * But device capable of gen$dev_link_speed x$dev_link_width" + fi + + echo "Payload: $dev_payload" + if [ $dev_payload -ne $max_payload ]; then + echo " * But device capable of $max_payload" + fi + + + info=0x`read_cfg 40` + max_tlp=$((2 ** (5 + ((info & 0xE0) >> 5)))) + echo "TLP: 32 dwords (transfering 32 TLP per request)" + if [ $max_tlp -ne 32 ]; then + echo " * But device is able to transfer TLP up to $max_tlp bytes" + fi + + # 2500 MT/s, but PCIe gen1 and gen2 uses 10 bit encoding + speed=$((link_width * link_speed * 2500 / 10)) +} + +parse_config diff --git a/tests/new_device.sh b/tests/new_device.sh deleted file mode 100755 index e3f8f8a..0000000 --- a/tests/new_device.sh +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/bash - -#Add new device to the driver -#echo "10ee 6028" > /sys/bus/pci/drivers/pciDriver/new_id -#Enable bus mastering -#setpci -s 03:00.0 4.w=0x07 diff --git a/tests/reload.sh b/tests/reload.sh new file mode 100755 index 0000000..62c6e22 --- /dev/null +++ b/tests/reload.sh @@ -0,0 +1,25 @@ +#! /bin/bash + +device=`lspci -n | grep -m 1 "10ee:" | awk '{print $1}'` +if [ -z "$device" ]; then + echo "Xilinx device doesn't exist, rescanning..." + echo 1 > /sys/bus/pci/rescan + exit +else + echo "Xilinx is located at: " $device +fi +echo "remove driver" +rmmod pciDriver +echo "remove devices" +echo 1 > /sys/bus/pci/devices/0000\:${device:0:2}\:${device:3:4}/remove +sleep 1 +echo "rescan" +echo 1 > /sys/bus/pci/rescan +sleep 1 +echo "instantiate driver" +modprobe pciDriver +# for devices with different ID +#echo "10ee 6028" > /sys/bus/pci/drivers/pciDriver/new_id +pci -i +#echo Enabling bus mastering on device $dev +#setpci -s $device 4.w=0x07 |