/alps/ipecamera

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/ipecamera

« back to all changes in this revision

Viewing changes to tests/dma/xilinx/xilinx_dma_static_mem.sh

  • Committer: Suren A. Chilingaryan
  • Date: 2015-04-27 00:28:57 UTC
  • Revision ID: csa@suren.me-20150427002857-82fk6r3e8rfgy4wr
First stand-alone ipecamera implementation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/bash
2
 
 
3
 
BAR=0
4
 
USE=1
5
 
ITERATIONS=1
6
 
TLP_SIZE=32
7
 
BUFFER_SIZE=8
8
 
 
9
 
function pci {
10
 
    PCILIB_PATH=`pwd`/..
11
 
    LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/pci $*
12
 
}
13
 
 
14
 
 
15
 
function reset {
16
 
    pci -b $BAR -w 0 1
17
 
    usleep 1000
18
 
    pci -b $BAR -w 0 0
19
 
    pci -b $BAR -w 4 0
20
 
}
21
 
 
22
 
function read_cfg {
23
 
#    echo $1 1>&2
24
 
    pci -a config -r 0x$1 | awk '{ print $2; }'
25
 
}
26
 
 
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"
32
 
    else
33
 
        model="Xilinx $model"
34
 
    fi
35
 
    version=$(((info >> 8) & 0xFF))
36
 
    data_width=$((16 * (2 ** ((info >> 16) & 0xF))))
37
 
    
38
 
    echo "$model, build $version, $data_width bits"
39
 
 
40
 
 
41
 
    next=`read_cfg 34 | cut -c 7-8`
42
 
 
43
 
    while [ $next -ne 0 ]; do
44
 
        cap=`read_cfg $next`
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`
51
 
 
52
 
            link_speed=$((((0x$pcie_link2 & 0xF0000) >> 16)))
53
 
            link_width=$((((0x$pcie_link2 & 0x3F00000) >> 20)))
54
 
 
55
 
            dev_link_speed=$((((0x$pcie_link1 & 0xF))))
56
 
            dev_link_width=$((((0x$pcie_link1 & 0x3F0) >> 4)))
57
 
        fi
58
 
        next=`echo $cap | cut -c 5-6`
59
 
    done
60
 
 
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"
64
 
    fi
65
 
    
66
 
    info=0x`read_cfg 40`
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"
71
 
    fi
72
 
    
73
 
    # 2500 MT/s, but PCIe gen1 and gen2 uses 10 bit encoding
74
 
    speed=$((link_width * link_speed * 2500 / 10))
75
 
}
76
 
 
77
 
reset
78
 
parse_config
79
 
 
80
 
pci --enable-irq
81
 
pci --acknowledge-irq
82
 
 
83
 
# TLP size
84
 
pci -b $BAR -w 0x0C 0x`echo "obase=16; $TLP_SIZE" | bc`
85
 
# TLP count
86
 
pci -b $BAR -w 0x10 0x`echo "obase=16; $BUFFER_SIZE * 1024 * 1024 / $TLP_SIZE / 4" | bc`
87
 
# Data
88
 
pci -b $BAR -w 0x14 0x13131313
89
 
 
90
 
bus="80000000"
91
 
dmaperf=0
92
 
for i in `seq 1 $ITERATIONS`; do
93
 
  for addr in $bus; do 
94
 
    pci -b $BAR -w 0x08 0x$addr
95
 
 
96
 
#Trigger
97
 
    pci -b $BAR -w 0x04 0x01
98
 
    pci --wait-irq
99
 
 
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"
103
 
    fi
104
 
 
105
 
    dmaperf=$((dmaperf + 0x`pci -b $BAR -r 0x28 | awk '{print $2}'`))
106
 
    reset
107
 
  done
108
 
done
109
 
 
110
 
pci --free-kernel-memory $USE
111
 
pci --disable-irq
112
 
 
113
 
echo
114
 
# Don't ask me about this formula
115
 
echo "Performance reported by FPGA: $(($BUFFER_SIZE * 1024 * 1024 * ITERATIONS * $speed / $dmaperf / 8)) MB/s"
116
 
 
117
 
#pci -b $BAR  -r 0 -s 32