bzr branch
http://suren.me/webbzr/alps/pcitool
266
by Suren A. Chilingaryan
Add forgotten ipe_benchmark.c |
1 |
#! /bin/bash
|
2 |
||
3 |
BAR=0 |
|
4 |
||
5 |
function pci { |
|
6 |
PCILIB_PATH=`pwd`/.. |
|
7 |
LD_LIBRARY_PATH="$PCILIB_PATH/pcilib" $PCILIB_PATH/pcitool/pci $* |
|
8 |
}
|
|
9 |
||
10 |
||
11 |
function read_cfg { |
|
12 |
pci -a config -r 0x$1 | awk '{ print $2; }' | sed -e 's/\s*//g' -e '/^\s*$/d' |
|
13 |
}
|
|
14 |
||
15 |
function parse_config { |
|
16 |
info=0x`pci -b $BAR -r 0 | awk '{ print $2; }' | sed -e 's/\s*//g' -e '/^\s*$/d'` |
|
17 |
model=`printf "%X" $((info>>24))` |
|
18 |
if [ $model -eq 14 ]; then |
|
19 |
model="Xilinx Virtex-6" |
|
20 |
else
|
|
21 |
model="Xilinx $model" |
|
22 |
fi
|
|
23 |
version=$(((info >> 8) & 0xFF)) |
|
24 |
data_width=$((16 * (2 ** ((info >> 16) & 0xF)))) |
|
25 |
||
26 |
echo "$model, build $version, $data_width bits" |
|
27 |
||
28 |
||
29 |
next=`read_cfg 34 | cut -c 7-8` |
|
30 |
# next=`printf "%u" $next`
|
|
31 |
||
32 |
while [ $((0x$next)) -ne 0 ]; do |
|
33 |
cap=`read_cfg $next` |
|
34 |
capid=`echo $cap | cut -c 7-8` |
|
35 |
if [ $capid -eq 10 ]; then |
|
36 |
addr=`printf "%X" $((0x$next + 4))` |
|
37 |
device_capabilities=`read_cfg $addr` |
|
38 |
||
39 |
addr=`printf "%X" $((0x$next + 8))` |
|
40 |
device_control=`read_cfg $addr` |
|
41 |
||
42 |
addr=`printf "%X" $((0x$next + 12))` |
|
43 |
pcie_link1=`read_cfg $addr` |
|
44 |
addr=`printf "%X" $((0x$next + 16))` |
|
45 |
pcie_link2=`read_cfg $addr` |
|
46 |
||
47 |
link_speed=$((((0x$pcie_link2 & 0xF0000) >> 16))) |
|
48 |
link_width=$((((0x$pcie_link2 & 0x3F00000) >> 20))) |
|
49 |
||
50 |
dev_link_speed=$((((0x$pcie_link1 & 0xF)))) |
|
51 |
dev_link_width=$((((0x$pcie_link1 & 0x3F0) >> 4))) |
|
52 |
||
53 |
max_payload=$(((1 << ((0x$device_capabilities & 0x07) + 7)))) |
|
54 |
dev_payload=$(((1 << (((0x$device_capabilities >> 5) & 0x07) + 7)))) |
|
55 |
fi
|
|
56 |
next=`echo $cap | cut -c 5-6` |
|
57 |
done
|
|
58 |
||
59 |
echo "Link: PCIe gen$link_speed x$link_width" |
|
60 |
if [ $link_speed -ne $dev_link_speed -o $link_width -ne $dev_link_width ]; then |
|
61 |
echo " * But device capable of gen$dev_link_speed x$dev_link_width" |
|
62 |
fi
|
|
63 |
||
64 |
echo "Payload: $dev_payload" |
|
65 |
if [ $dev_payload -ne $max_payload ]; then |
|
66 |
echo " * But device capable of $max_payload" |
|
67 |
fi
|
|
68 |
||
69 |
||
70 |
info=0x`read_cfg 40` |
|
71 |
max_tlp=$((2 ** (5 + ((info & 0xE0) >> 5)))) |
|
72 |
echo "TLP: 32 dwords (transfering 32 TLP per request)" |
|
73 |
if [ $max_tlp -ne 32 ]; then |
|
74 |
echo " * But device is able to transfer TLP up to $max_tlp bytes" |
|
75 |
fi
|
|
76 |
||
77 |
# 2500 MT/s, but PCIe gen1 and gen2 uses 10 bit encoding
|
|
78 |
speed=$((link_width * link_speed * 2500 / 10)) |
|
79 |
}
|
|
80 |
||
81 |
parse_config |