10
LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/pci $*
23
pci -a config -r 0x$1 | awk '{ print $2; }'
26
function parse_config {
27
info=0x`pci -b $BAR -r 0 | awk '{ print $2; }'`
28
model=`printf "%X" $((info>>24))`
29
if [ $model -eq 14 ]; then
30
model="Xilinx Virtex-6"
34
version=$(((info >> 8) & 0xFF))
35
data_width=$((16 * (2 ** ((info >> 16) & 0xF))))
37
echo "$model, build $version, $data_width bits"
40
next=`read_cfg 34 | cut -c 7-8`
42
while [ $next -ne 0 ]; do
44
capid=`echo $cap | cut -c 7-8`
45
if [ $capid -eq 10 ]; then
46
addr=`printf "%X" $((0x$next + 12))`
47
pcie_link1=`read_cfg $addr`
48
addr=`printf "%X" $((0x$next + 16))`
49
pcie_link2=`read_cfg $addr`
51
link_speed=$((((0x$pcie_link2 & 0xF0000) >> 16)))
52
link_width=$((((0x$pcie_link2 & 0x3F00000) >> 20)))
54
dev_link_speed=$((((0x$pcie_link1 & 0xF))))
55
dev_link_width=$((((0x$pcie_link1 & 0x3F0) >> 4)))
57
next=`echo $cap | cut -c 5-6`
60
echo "Link: PCIe gen$link_speed x$link_width"
61
if [ $link_speed -ne $dev_link_speed -o $link_width -ne $dev_link_width ]; then
62
echo " * But device capable of gen$dev_link_speed x$dev_link_width"
66
max_tlp=$((2 ** (5 + ((info & 0xE0) >> 5))))
67
echo "TLP: 32 dwords (transfering 32 TLP per request)"
68
if [ $max_tlp -ne 32 ]; then
69
echo " * But device is able to transfer TLP up to $max_tlp bytes"
72
# 2500 MT/s, but PCIe gen1 and gen2 uses 10 bit encoding
73
speed=$((link_width * link_speed * 2500 / 10))
82
pci --free-kernel-memory $USE
83
pci --alloc-kernel-memory $USE --type c2s -s $BUFFERS
84
bus=`pci --list-kernel-memory 00100001 | awk '{ print $4; }' | grep 00`
85
#ptr=`pci --list-kernel-memory 00100001 | awk '{ print $2; }' | grep 00`
88
pci -b $BAR -w 0x0C 0x20
90
pci -b $BAR -w 0x10 0x20
92
pci -b $BAR -w 0x14 0x13131313
95
for i in `seq 1 $ITERATIONS`; do
97
pci -b $BAR -w 0x08 0x$addr
100
pci -b $BAR -w 0x04 0x01
102
# pci -b $BAR -w 0x04 0x00
104
status=`pci -b $BAR -r 0x04 | awk '{print $2; }' | cut -c 5-8`
105
if [ $status != "0101" ]; then
106
echo "Read failed, invalid status: $status"
109
dmaperf=$((dmaperf + 0x`pci -b $BAR -r 0x28 | awk '{print $2}'`))
114
pci --free-kernel-memory $USE
118
# Don't ask me about this formula
119
echo "Performance reported by FPGA: $((4096 * BUFFERS * ITERATIONS * $speed / $dmaperf / 8)) MB/s"
121
#pci -b $BAR -r 0 -s 32