11
LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/pci $*
24
pci -a config -r 0x$1 | awk '{ print $2; }'
27
function parse_config {
28
info=0x`pci -b $BAR -r 0 | awk '{ print $2; }'`
29
model=`printf "%X" $((info>>24))`
30
if [ $model -eq 14 ]; then
31
model="Xilinx Virtex-6"
35
version=$(((info >> 8) & 0xFF))
36
data_width=$((16 * (2 ** ((info >> 16) & 0xF))))
38
echo "$model, build $version, $data_width bits"
41
next=`read_cfg 34 | cut -c 7-8`
43
while [ $next -ne 0 ]; do
45
capid=`echo $cap | cut -c 7-8`
46
if [ $capid -eq 10 ]; then
47
addr=`printf "%X" $((0x$next + 12))`
48
pcie_link1=`read_cfg $addr`
49
addr=`printf "%X" $((0x$next + 16))`
50
pcie_link2=`read_cfg $addr`
52
link_speed=$((((0x$pcie_link2 & 0xF0000) >> 16)))
53
link_width=$((((0x$pcie_link2 & 0x3F00000) >> 20)))
55
dev_link_speed=$((((0x$pcie_link1 & 0xF))))
56
dev_link_width=$((((0x$pcie_link1 & 0x3F0) >> 4)))
58
next=`echo $cap | cut -c 5-6`
61
echo "Link: PCIe gen$link_speed x$link_width"
62
if [ $link_speed -ne $dev_link_speed -o $link_width -ne $dev_link_width ]; then
63
echo " * But device capable of gen$dev_link_speed x$dev_link_width"
67
max_tlp=$((2 ** (5 + ((info & 0xE0) >> 5))))
68
echo "TLP: 32 dwords (transfering 32 TLP per request)"
69
if [ $max_tlp -ne $TLP_SIZE ]; then
70
echo " * But device is able to transfer TLP up to $max_tlp bytes"
73
# 2500 MT/s, but PCIe gen1 and gen2 uses 10 bit encoding
74
speed=$((link_width * link_speed * 2500 / 10))
84
pci -b $BAR -w 0x0C 0x`echo "obase=16; $TLP_SIZE" | bc`
86
pci -b $BAR -w 0x10 0x`echo "obase=16; $BUFFER_SIZE * 1024 * 1024 / $TLP_SIZE / 4" | bc`
88
pci -b $BAR -w 0x14 0x13131313
92
for i in `seq 1 $ITERATIONS`; do
94
pci -b $BAR -w 0x08 0x$addr
97
pci -b $BAR -w 0x04 0x01
100
status=`pci -b $BAR -r 0x04 | awk '{print $2; }' | cut -c 5-8`
101
if [ $status != "0101" ]; then
102
echo "Read failed, invalid status: $status"
105
dmaperf=$((dmaperf + 0x`pci -b $BAR -r 0x28 | awk '{print $2}'`))
110
pci --free-kernel-memory $USE
114
# Don't ask me about this formula
115
echo "Performance reported by FPGA: $(($BUFFER_SIZE * 1024 * 1024 * ITERATIONS * $speed / $dmaperf / 8)) MB/s"
117
#pci -b $BAR -r 0 -s 32