summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarthik Ramanan2015-09-03 02:06:12 -0500
committerKarthik Ramanan2015-09-03 04:41:16 -0500
commit6e10816e18c2d274479f62e3d953e558eb23bff2 (patch)
tree25ef30fa9f31de700b5156788a5eb93f7933e69a
parent85006e48fbf6e7664699a8d0944013e1f80e8e73 (diff)
downloadexample-applications-6e10816e18c2d274479f62e3d953e558eb23bff2.tar.gz
example-applications-6e10816e18c2d274479f62e3d953e558eb23bff2.tar.xz
example-applications-6e10816e18c2d274479f62e3d953e558eb23bff2.zip
bandwidth-tool: Initial version
This is using the statcollector registers and allows configuring the tool using two config files: 1. config.ini 2. initiator.cfg This also contains host side tools to help visualize the data Refer to the GLSDK Software Developers Guide for detailed usage information. Signed-off-by: Karthik Ramanan <a0393906@ti.com>
-rw-r--r--Makefile.am2
-rw-r--r--bandwidth-tool/Dra7xx_ddrstat_speed.c481
-rw-r--r--bandwidth-tool/Makefile.am6
-rw-r--r--bandwidth-tool/config.ini8
-rw-r--r--bandwidth-tool/host/EMIF_plotter.py80
-rw-r--r--bandwidth-tool/host/configstat.ini5
-rw-r--r--bandwidth-tool/host/statcoll_plot.py185
-rw-r--r--bandwidth-tool/initiators.cfg16
-rw-r--r--bandwidth-tool/statcoll.c1029
-rw-r--r--bandwidth-tool/statcoll.h152
-rw-r--r--configure.ac2
11 files changed, 1964 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 387259b..0086abb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
1SUBDIRS = vpe vip drm-tests thermal messageq/messageq_ipc_linux gst 1SUBDIRS = vpe vip drm-tests thermal messageq/messageq_ipc_linux gst bandwidth-tool
2 2
3if HAVE_GST 3if HAVE_GST
4SUBDIRS = . gst 4SUBDIRS = . gst
diff --git a/bandwidth-tool/Dra7xx_ddrstat_speed.c b/bandwidth-tool/Dra7xx_ddrstat_speed.c
new file mode 100644
index 0000000..0a20509
--- /dev/null
+++ b/bandwidth-tool/Dra7xx_ddrstat_speed.c
@@ -0,0 +1,481 @@
1/*
2 * Copyright (C) 2015 Texas Instruments
3 * Author: Karthik Ramanan <karthik.ramanan@ti.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include <stdio.h>
19#include <stdlib.h>
20#include <stdint.h>
21#include <string.h>
22#include <sys/mman.h>
23#include <sys/time.h>
24#include <unistd.h>
25#include <fcntl.h>
26#include "statcoll.h"
27
28#define PAGE_SIZE 4096
29
30#define EMIF1_BASE 0x4c000000
31#define EMIF2_BASE 0x4d000000
32
33#define EMIF_PERF_CNT_1 0x80
34#define EMIF_PERF_CNT_2 0x84
35#define EMIF_PERF_CNT_CFG 0x88
36#define EMIF_PERF_CNT_TIM 0x90
37
38static unsigned
39tv_diff(struct timeval *tv1, struct timeval *tv2)
40{
41 return (tv2->tv_sec - tv1->tv_sec) * 1000000 +
42 (tv2->tv_usec - tv1->tv_usec);
43}
44
45
46struct emif_perf {
47 int code;
48 const char *name;
49};
50
51static const struct emif_perf emif_perf_tab[] = {
52 { 0, "access" },
53 { 1, "activate" },
54 { 2, "read" },
55 { 3, "write" },
56 { 4, "fifo_cmd" },
57 { 5, "fifo_write" },
58 { 6, "fifo_read" },
59 { 7, "fifo_ret" },
60 { 8, "prio" },
61 { 9, "cmd_pend" },
62 { 10, "data" },
63};
64
65static void *emif1, *emif2;
66static int BANDWIDTH=0;
67static int DELAY = 1;
68static int EMIF_PERF_CFG1 = 9;
69static int EMIF_PERF_CFG2 = 10;
70
71
72static int STATCOLL=0;
73static int TOTAL_TIME;
74static int INTERVAL_US;
75
76struct timeval t1, t2;
77
78FILE* outfile;
79struct emif_stats {
80 uint32_t cycles;
81 uint32_t cnt1;
82 uint32_t cnt2;
83};
84
85static struct emif_stats emif1_start, emif1_end;
86static struct emif_stats emif2_start, emif2_end;
87
88static void *emif_init(int fd, unsigned base)
89{
90 void *mem =
91 mmap(NULL, PAGE_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, base);
92 volatile uint32_t *emif = mem,temp;
93
94 if (mem == MAP_FAILED){
95 return NULL;
96 }
97
98 emif[EMIF_PERF_CNT_CFG>>2] = EMIF_PERF_CFG2 << 16 | EMIF_PERF_CFG1;
99
100 return mem;
101}
102
103static void emif_read(volatile uint32_t *emif, struct emif_stats *st)
104{
105 st->cycles = emif[EMIF_PERF_CNT_TIM>>2];
106 st->cnt1 = emif[EMIF_PERF_CNT_1>>2];
107 st->cnt2 = emif[EMIF_PERF_CNT_2>>2];
108}
109
110static void emif_print(const char *tag, struct emif_stats *st1,
111 struct emif_stats *st2)
112{
113 uint32_t cycles = st2->cycles - st1->cycles;
114 uint32_t cnt1 = st2->cnt1 - st1->cnt1;
115 uint32_t cnt2 = st2->cnt2 - st1->cnt2;
116 printf("%s %s %2llu%% %s %2llu%%", tag,
117 emif_perf_tab[EMIF_PERF_CFG1].name, 100ull*cnt1/cycles,
118 emif_perf_tab[EMIF_PERF_CFG2].name, 100ull*cnt2/cycles);
119 fprintf(outfile,"%s%s= %2llu,%s%s= %2llu,",
120 tag, emif_perf_tab[EMIF_PERF_CFG1].name, 100ull*cnt1/cycles,
121 tag, emif_perf_tab[EMIF_PERF_CFG2].name, 100ull*cnt2/cycles);
122}
123
124static int perf_init(void)
125{
126 int fd = open("/dev/mem", O_RDWR);
127 int err = 0;
128
129 if (fd == -1){
130 printf("error fd=open() \n");
131 return -1;
132 }
133 emif1 = emif_init(fd, EMIF1_BASE);
134 emif2 = emif_init(fd, EMIF2_BASE);
135
136 if (!emif1 || !emif2){
137 printf("error if (!emif1 || !emif2) \n");
138 err = -1;
139 }
140
141 close(fd);
142 return err;
143}
144
145static void perf_start(void)
146{
147 if (emif1) {
148 emif_read(emif1, &emif1_start);
149 emif_read(emif2, &emif2_start);
150 }
151}
152
153static void perf_stop(void)
154{
155 if (emif1) {
156 emif_read(emif1, &emif1_end);
157 emif_read(emif2, &emif2_end);
158 }
159}
160
161static void perf_print(void)
162{
163 if (emif1) {
164 emif_print("EMIF1", &emif1_start, &emif1_end);
165 printf("\t");
166 emif_print("EMIF2", &emif2_start, &emif2_end);
167 printf("\r");
168 fprintf(outfile, "\n");
169 fflush(outfile);
170 fflush(stdout);
171 }
172}
173
174static void perf_close(void)
175{
176 if (emif1) munmap(emif1, PAGE_SIZE);
177 if (emif2) munmap(emif2, PAGE_SIZE);
178}
179
180static int get_cfg(const char *name, int def)
181{
182 char *end;
183 int n = strtol(name, &end, 0);
184 int i;
185
186 if (!*end)
187 return n;
188
189 for (i = 0; i < sizeof(emif_perf_tab)/sizeof(emif_perf_tab[0]); i++)
190 if (!strcmp(name, emif_perf_tab[i].name))
191 return emif_perf_tab[i].code;
192
193 return def;
194}
195
196
197unsigned int emif_freq()
198{
199 volatile unsigned *tim1;
200 unsigned v1, v2;
201 int fd;
202
203 /*calculation EMIF frequency
204 EMIF_PERF_CNT_TIM = \n32-bit counter that
205 continuously counts number for
206 EMIF_FCLK clock cycles elapsed
207 after EMIFis brought out of reset*/
208
209 fd = open("/dev/mem", O_RDONLY);
210 if (fd == -1) {
211 perror("/dev/mem");
212 return 1;
213 }
214
215 void *mem =
216 mem = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, EMIF1_BASE);
217 if (mem == MAP_FAILED) {
218 perror("mmap");
219 exit(1);
220 }
221
222 tim1 = (unsigned *)((char*)mem + EMIF_PERF_CNT_TIM);
223
224 v1 = *tim1;
225 gettimeofday(&t1, NULL);
226 sleep(2);
227 v2 = *tim1;
228 gettimeofday(&t2, NULL);
229
230 munmap(mem, PAGE_SIZE);
231 close(fd);
232
233 return (v2 - v1) / tv_diff(&t1, &t2);
234
235}
236
237
238char config_file_path[100];
239char keylist[][50] = {
240 "DELAY",
241 "EMIF_PERF_CFG1",
242 "EMIF_PERF_CFG2",
243 "BANDWIDTH",
244 "STATCOLL",
245 "TOTAL_TIME",
246 "INTERVAL_US",
247 "INITIATORS",
248};
249
250char line[512], *p;
251char tokens[6][512];
252int temp, flag = 0;
253char *keyvalue, *pair;
254char key[100];
255int linecount=0;
256
257
258int debug=0;
259
260void print_valid_options(void)
261{
262 int i;
263 printf("Invalid key found\n");
264 printf("Supported keys are :\n");
265 for(i=0; i<sizeof(keylist)/sizeof(keylist[0]); i++)
266 printf("\t\t %s\n", keylist[i]);
267
268}
269int validatekey(char *ptr)
270{
271 int i;
272 for(i=0; i<sizeof(keylist)/sizeof(keylist[0]); i++)
273 if(strcmp(ptr, keylist[i]) == 0)
274 return 0;
275
276 return 1;
277}
278
279void add_key_value(char *key, int value)
280{
281 printd("%s", "Inside add_key_value\n");
282
283 if(strcmp(key, "BANDWIDTH") == 0) {
284 BANDWIDTH = value;
285 return;
286 }
287 if(strcmp(key, "STATCOLL") == 0) {
288 STATCOLL = value;
289 return;
290 }
291 else
292 printd("%s", "********** UNKNOWN**********");
293
294 if(BANDWIDTH == 1) {
295 if(strcmp(key, "DELAY") == 0)
296 DELAY = value;
297 else if(strcmp(key, "EMIF_PERF_CFG1") == 0)
298 EMIF_PERF_CFG1 = value;
299 else if(strcmp(key, "EMIF_PERF_CFG2") == 0)
300 EMIF_PERF_CFG2 = value;
301 }
302 else
303 printf("NOTE: BANDWIDTH is not enabled, ignoring %s\n", key);
304
305
306 if(STATCOLL == 1) {
307 if(strcmp(key, "INTERVAL_US") == 0)
308 INTERVAL_US = value;
309 else if(strcmp(key, "TOTAL_TIME") == 0)
310 TOTAL_TIME = value;
311 }
312 else
313 printf("NOTE: STATCOLL is not enabled, ignoring %s\n", key);
314}
315
316void bandwidth_usage() {
317
318 printf("#########################################################\n##\n"
319
320 "## usage : ./Dra7xx_ddrstat <DELAY> <EMIF_PERF_CFG1> <EMIF_PERF_CFG2> \n"
321 "## default : DELAY=1 EMIF_PERF_CFG1=9 EMIF_PERF_CFG2=10\n"
322 "## option : for EMIF_PERF_CFG1 and EMIF_PERF_CFG2\n"
323 "## 0 -> access,\n"
324 "## 1 -> activate,\n"
325 "## 2 -> read,\n"
326 "## 3 -> write,\n"
327 "## 4 -> fifo_cmd,\n"
328 "## 5 -> fifo_write,\n"
329 "## 6 -> fifo_read,\n"
330 "## 7 -> fifo_ret,\n"
331 "## 8 -> prio,\n"
332 "## 9 -> cmd_pend,\n"
333 "## 10 -> data \n##\n"
334
335 "## EMIF frq : %d MHz\n\n", emif_freq() );
336}
337
338
339int main(int argc, char **argv)
340{
341 int option;
342 FILE *fp;
343 int i;
344
345
346
347 /* Read config file */
348 /* Initialize this to turn off verbosity of getopt */
349 opterr = 0;
350
351 while ((option = getopt (argc, argv, "df:")) != -1)
352 {
353 switch(option)
354 {
355 case 'f':
356 strcpy(config_file_path, optarg);
357 break;
358 case 'd':
359 debug=1;
360 break;
361 default:
362 printf("Invalid option.. Exiting\n");
363 exit(0);
364 }
365 }
366
367 fp = fopen(config_file_path, "r");
368 if (fp == NULL) {
369 fprintf(stderr, "couldn't open the specified file\n");
370 return -1;
371 }
372
373 while (fgets(line, sizeof line, fp)) {
374 printd("Line is = %s", line);
375
376 if (line[0] == '#' || line[0] == '\n') {
377 continue;
378 }
379
380 memset(tokens, 0, sizeof(tokens));
381 i = 0;
382
383 pair = strtok (line," ,");
384 while (pair != NULL)
385 {
386 printd ("\tPair is = %s\n",pair);
387 strcpy(tokens[i++], pair);
388 pair = strtok (NULL, " ,.-");
389 }
390
391 for(temp=0; temp< i; temp++)
392 {
393 printd("Line %d: %s\n", temp, tokens[temp]);
394
395 keyvalue = strtok (tokens[temp]," =");
396 while (keyvalue != NULL)
397 {
398 if(flag == 0)
399 {
400 if(validatekey(keyvalue))
401 {
402 print_valid_options();
403 exit(0);
404 }
405 strcpy(key, keyvalue);
406 printd ("\tKey is = %s\n",key);
407 flag++;
408 }
409 else
410 {
411 printd ("\tValue is = %s",keyvalue);
412 printd (" (%d)\n", atoi(keyvalue));
413 add_key_value(key, atoi(keyvalue));
414 flag = 0;
415 }
416 keyvalue = strtok (NULL, " =");
417 }
418 }
419
420
421
422 linecount++;
423 printd("%s", "------------------- \n");
424
425 }
426
427 fclose(fp);
428
429 printf("\n\nCOMPLETED: Parsing of the user specified parameters.. \n \
430 \nConfiguring device now.. \n\n");
431 if(BANDWIDTH == 1) {
432 bandwidth_usage();
433 if (DELAY <= 0)
434 DELAY = 1;
435
436 if (perf_init()){
437 printf("perf_init return non zero \n");
438 return 1;
439 }
440
441 outfile = fopen("emif-performance.csv", "w+");
442 if (!outfile) {
443 printf("\n Error opening file");
444 }
445 for (;;) {
446 perf_start();
447 sleep(DELAY);
448 perf_stop();
449 perf_print();
450 }
451
452 fclose(outfile);
453 perf_close();
454 return 0;
455 }
456
457 if(STATCOLL == 1) {
458 printf("STATISTICS COLLECTOR option chosen\n");
459 printf("------------------------------------------------\n\n");
460 fp = fopen("initiators.cfg", "r");
461 if (fp == NULL) {
462 fprintf(stderr, "couldn't open the specified file initiators.cfg'\n");
463 return -1;
464 }
465
466 int i=0;
467 char list[100][50];
468 memset(list, sizeof(list), 0);
469 while (fgets(line, sizeof line, fp)) {
470 printd("Line is = %s", line);
471 /* Slightly strange way to chop off the \n character */
472 strtok(line, "\n");
473 strcpy(list[i++], line);
474 }
475 fclose(fp);
476
477 statcoll_start(TOTAL_TIME, INTERVAL_US, list);
478 }
479
480}
481
diff --git a/bandwidth-tool/Makefile.am b/bandwidth-tool/Makefile.am
new file mode 100644
index 0000000..57f5d21
--- /dev/null
+++ b/bandwidth-tool/Makefile.am
@@ -0,0 +1,6 @@
1bin_PROGRAMS = glsdkstatcoll
2
3glsdkstatcoll_CFLAGS = \
4 -O0 -g --static
5
6glsdkstatcoll_SOURCES = statcoll.c Dra7xx_ddrstat_speed.c
diff --git a/bandwidth-tool/config.ini b/bandwidth-tool/config.ini
new file mode 100644
index 0000000..3c5e59e
--- /dev/null
+++ b/bandwidth-tool/config.ini
@@ -0,0 +1,8 @@
1BANDWIDTH=0
2 DELAY=5
3 EMIF_PERF_CFG1=9
4 EMIF_PERF_CFG2=10
5
6STATCOLL=1
7 TOTAL_TIME=12
8 INTERVAL_US=30000
diff --git a/bandwidth-tool/host/EMIF_plotter.py b/bandwidth-tool/host/EMIF_plotter.py
new file mode 100644
index 0000000..7b2cc12
--- /dev/null
+++ b/bandwidth-tool/host/EMIF_plotter.py
@@ -0,0 +1,80 @@
1# Script to plot the EMIF bandwidth in a continous basis
2#
3# Author: Karthik Ramanan (karthik.ramanan@ti.com)
4#
5# License: BSD
6#
7
8import ConfigParser
9import os
10import datetime
11import time
12import csv
13from pylab import *
14import pylab as pl
15import matplotlib.gridspec as gridspec
16
17config = ConfigParser.ConfigParser()
18config.read('config.ini')
19print config.items('core')
20
21IPADDRESS=config.get('core','ipaddress')
22PATH=config.get('core','path')
23DELAY=config.getint('core','refreshrate')
24
25print "IPAddress is " + IPADDRESS
26print "Path is " + PATH
27print DELAY
28
29UNIQUE = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
30OUTFILE = UNIQUE + ".csv"
31print OUTFILE
32
33cmd = "scp root@" + IPADDRESS + ":" + PATH + " " + OUTFILE
34print cmd
35os.system(cmd)
36
37if os.path.isfile(OUTFILE) == False:
38 exit
39else:
40 print "File found"
41
42
43pl.figure(figsize=(10, 10))
44pl.ion()
45pl.show()
46
47while (True):
48 ARRAY = []
49 cols=0
50 os.system(cmd);
51 ifile = open(OUTFILE, "rb")
52 reader = csv.reader(ifile)
53 for row in reader:
54 totalcolumns = len(row) - 1
55 break
56 ifile.seek(0)
57
58
59 gs = gridspec.GridSpec(4, 1)
60 while (cols < totalcolumns):
61 for row in reader:
62 ARRAY.append(row[cols].split('=')[1])
63
64 title=row[cols].split('=')[0]
65 pl.subplot(gs[cols, :])
66 pl.ylim([0,100])
67 pl.title(title, fontsize=10)
68 pl.grid(b=None, which='major', axis='both', color='r')
69 pl.plot(ARRAY,'g-')
70
71 cols+=1
72 ifile.seek(0)
73 ARRAY = []
74
75 pl.draw()
76 time.sleep(DELAY)
77 ifile.close()
78
79exit
80
diff --git a/bandwidth-tool/host/configstat.ini b/bandwidth-tool/host/configstat.ini
new file mode 100644
index 0000000..46c8bd1
--- /dev/null
+++ b/bandwidth-tool/host/configstat.ini
@@ -0,0 +1,5 @@
1[core]
2ipaddress=172.24.190.172
3path=/home/root/statcollector.csv
4refreshrate=5
5
diff --git a/bandwidth-tool/host/statcoll_plot.py b/bandwidth-tool/host/statcoll_plot.py
new file mode 100644
index 0000000..7d5c94e
--- /dev/null
+++ b/bandwidth-tool/host/statcoll_plot.py
@@ -0,0 +1,185 @@
1# Script to plot the EMIF bandwidth in a continous basis
2#
3# Author: Karthik Ramanan (karthik.ramanan@ti.com)
4#
5# License: BSD
6#
7
8import ConfigParser
9import os
10import datetime
11import time
12import csv
13from pylab import *
14import pylab as pl
15import matplotlib.gridspec as gridspec
16
17IPADDRESS="dummy"
18PATH="default"
19DELAY=5
20OUTFILE="default.csv"
21OPTION="-x"
22INTERVAL_US=30000
23
24def parse_arguments():
25 global IPADDRESS, PATH, DELAY, OUTFILE, OPTION
26
27 config = ConfigParser.ConfigParser()
28 config.read('configstat.ini')
29 print config.items('core')
30
31 IPADDRESS=config.get('core','ipaddress')
32 PATH=config.get('core','path')
33 DELAY=config.getint('core','refreshrate')
34
35 print "IPAddress is " + IPADDRESS
36 print "Path is " + PATH
37 print DELAY
38
39 if OPTION != "-f":
40 unique = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
41 OUTFILE = unique + ".csv"
42 print OUTFILE
43
44 cmd = "scp root@" + IPADDRESS + ":" + PATH + " " + OUTFILE
45 print cmd
46 os.system(cmd)
47
48 if os.path.isfile(OUTFILE) == False:
49 exit
50 else:
51 print "File found"
52
53def plot_graphs():
54 pl.figure()
55
56 ARRAY = []
57 cols=0
58 ifile = open(OUTFILE, "rb")
59 reader = csv.reader(ifile)
60 for row in reader:
61 totalcolumns = len(row) - 1
62 break
63 ifile.seek(0)
64
65
66 EMIF_SYS1 = []
67 EMIF_SYS2 = []
68 gs = gridspec.GridSpec(1, 1)
69 while (cols < totalcolumns):
70 #print 'Reading column number: ' + str(cols)
71 for row in reader:
72 ARRAY.append(int(row[cols].split('=')[1]))
73
74 title=row[cols].split('=')[0]
75 if title == 'STATCOL_EMIF1_SYS ':
76 print "Ignoring " + title
77 EMIF_SYS1 = list(ARRAY)
78 cols+=1
79 ifile.seek(0)
80 ARRAY = []
81 continue
82 elif title == 'STATCOL_EMIF2_SYS ':
83 print "Ignoring " + title
84 EMIF_SYS2 = list(ARRAY)
85 cols+=1
86 ifile.seek(0)
87 ARRAY = []
88 continue
89
90 if ARRAY.count(0) == (len(ARRAY)):
91 print "All elements are zero for " + title
92 cols+=1
93 ifile.seek(0)
94 ARRAY = []
95 continue
96 else:
97 print "Plotting graph for " + title
98
99 pl.plot(ARRAY, label=title)
100
101 cols+=1
102 ifile.seek(0)
103 ARRAY = []
104
105 TOTAL=[]
106 counter=0
107 for item in EMIF_SYS1:
108 TOTAL.append(int(EMIF_SYS1[counter]) + int(EMIF_SYS2[counter]))
109 counter+=1
110
111 pl.title("J6 L3 Bandwidth stats plot", fontsize=10)
112 pl.plot(TOTAL, label='TOTAL')
113
114 legend = pl.legend()
115 pl.xlabel("Sample no")
116 pl.ylabel("Bytes per sample")
117 ifile.close()
118
119 pl.show()
120
121def display_average():
122 ARRAY = []
123 cols=0
124 ifile = open(OUTFILE, "rb")
125 reader = csv.reader(ifile)
126 for row in reader:
127 totalcolumns = len(row) - 1
128 break
129 ifile.seek(0)
130
131
132 EMIF_SYS1 = []
133 EMIF_SYS2 = []
134 print "-------------------------------------------------------------------"
135 print " Initiator Average Peak Average(active)"
136 print "-------------------------------------------------------------------"
137 while (cols < totalcolumns):
138 for row in reader:
139 ARRAY.append(int(row[cols].split('=')[1]))
140
141 title=row[cols].split('=')[0]
142 cols+=1
143 ifile.seek(0)
144 #print ARRAY
145 summ=0
146 for items in ARRAY:
147 summ += (items * 1000/30)
148 total=len(ARRAY)
149 #print "Sum is " + str(summ)
150 #print "Total is " + str(total)
151 #print title + " Average is " + str((summ/total)/1000000) + " Mbps"
152 #print str.ljust(title,20," ") + str.rjust(str(round((summ/total)/1000000, 2)), 30, " ")
153 print str.ljust(title,25," ") + str.rjust(str(round((summ/total)/1000000, 2)), 12, " ") + str.rjust(str(round(max(ARRAY)/INTERVAL_US, 2)), 10," ") + str.rjust(str(round((summ/(len([x for x in ARRAY if x > 0])+1)/1000000), 2)),10, " ") + " (" + str(len([x for x in ARRAY if x > 0])) + ")"
154 #print "Non zero elements in list is " + str(len([x for x in ARRAY if x > 0]))
155
156 ARRAY = []
157
158 ifile.close()
159 print "-------------------------------------------------------------------"
160 print "-------------------------------------------------------------------\n"
161
162#main
163print "Number of arguments " + str(len(sys.argv))
164print "Arguments = " + str(sys.argv)
165
166if len(sys.argv) == 1:
167 print "Only one argument. Will parse all arguments from the config file"
168else:
169 OUTFILE = str(sys.argv[2])
170 OPTION = str(sys.argv[1])
171 print "New command" + str(sys.argv[2])
172 print "File is " + OUTFILE
173 print "option is " + OPTION
174 if OPTION == "-f":
175 print "Local file option provided.. "
176
177 if os.path.isfile(OUTFILE) == False:
178 print "File not found"
179 sys.exit()
180 else:
181 print "Local file found.. "
182
183parse_arguments()
184display_average()
185plot_graphs()
diff --git a/bandwidth-tool/initiators.cfg b/bandwidth-tool/initiators.cfg
new file mode 100644
index 0000000..7ed72fc
--- /dev/null
+++ b/bandwidth-tool/initiators.cfg
@@ -0,0 +1,16 @@
1STATCOL_EMIF1_SYS
2STATCOL_EMIF2_SYS
3STATCOL_IVA
4STATCOL_DSS
5STATCOL_GPU_P1
6STATCOL_GPU_P2
7STATCOL_MA_MPU_P1
8STATCOL_MA_MPU_P2
9STATCOL_BB2D_P1
10STATCOL_BB2D_P2
11STATCOL_VIP1_P1
12STATCOL_VIP1_P2
13STATCOL_VIP2_P1
14STATCOL_VIP2_P2
15STATCOL_VIP3_P1
16STATCOL_VIP3_P2
diff --git a/bandwidth-tool/statcoll.c b/bandwidth-tool/statcoll.c
new file mode 100644
index 0000000..3dd138b
--- /dev/null
+++ b/bandwidth-tool/statcoll.c
@@ -0,0 +1,1029 @@
1/*
2 * Copyright (c) 2015, Texas Instruments Incorporated
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of Texas Instruments Incorporated nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
33/**
34 * @file statcoll.c
35 * @authors Karthik Ramanan <karthik.ramanan@ti.com>
36 *
37 * Adapted to Linux with changes in framework from original example
38 * from prash@ti.com
39 *
40 * @brief Linux utility to configure and read the statistics collectors
41 * on the Jacinto 6 SoC
42 *
43 *
44 */
45#include <stdio.h>
46#include <stdlib.h>
47#include <string.h>
48#include <sys/mman.h>
49#include <fcntl.h>
50
51#include "statcoll.h"
52
53#define ENABLE_MODE 0x0
54#define READ_STATUS_MODE 0x1
55
56//#define DUMMY_MODE
57
58const struct list_of_initiators initiators[STATCOL_MAX] =
59{
60 { STATCOL_EMIF1_SYS, "STATCOL_EMIF1_SYS" },
61 { STATCOL_EMIF2_SYS,"STATCOL_EMIF2_SYS" },
62 { STATCOL_MA_MPU_P1,"STATCOL_MA_MPU_P1" },
63 { STATCOL_MA_MPU_P2,"STATCOL_MA_MPU_P2" },
64 { STATCOL_MPU1,"STATCOL_MPU1" },
65 { STATCOL_MMU1,"STATCOL_MMU1" },
66 { STATCOL_TPTC_RD1,"STATCOL_TPTC_RD1" },
67 { STATCOL_TPTC_WR1,"STATCOL_TPTC_WR1" },
68 { STATCOL_TPTC_RD2,"STATCOL_TPTC_RD2" },
69 { STATCOL_TPTC_WR2,"STATCOL_TPTC_WR2" },
70 { STATCOL_VIP1_P1,"STATCOL_VIP1_P1" },
71 { STATCOL_VIP1_P2,"STATCOL_VIP1_P2" },
72 { STATCOL_VIP2_P1,"STATCOL_VIP2_P1" },
73 { STATCOL_VIP2_P2,"STATCOL_VIP2_P2" },
74 { STATCOL_VIP3_P1,"STATCOL_VIP3_P1" },
75 { STATCOL_VIP3_P2,"STATCOL_VIP3_P2" },
76 { STATCOL_VPE_P1,"STATCOL_VPE_P1" },
77 { STATCOL_VPE_P2,"STATCOL_VPE_P2" },
78 { STATCOL_EVE1_TC0,"STATCOL_EVE1_TC0" },
79 { STATCOL_EVE1_TC1,"STATCOL_EVE1_TC1" },
80 { STATCOL_EVE2_TC0,"STATCOL_EVE2_TC0" },
81 { STATCOL_EVE2_TC1,"STATCOL_EVE2_TC1" },
82 { STATCOL_EVE3_TC0,"STATCOL_EVE3_TC0" },
83 { STATCOL_EVE3_TC1,"STATCOL_EVE3_TC1" },
84 { STATCOL_EVE4_TC0,"STATCOL_EVE4_TC0" },
85 { STATCOL_EVE4_TC1,"STATCOL_EVE4_TC1" },
86 { STATCOL_DSP1_MDMA,"STATCOL_DSP1_MDMA" },
87 { STATCOL_DSP1_EDMA,"STATCOL_DSP1_EDMA" },
88 { STATCOL_DSP2_MDMA,"STATCOL_DSP2_MDMA" },
89 { STATCOL_DSP2_EDMA,"STATCOL_DSP2_EDMA" },
90 { STATCOL_IVA,"STATCOL_IVA" },
91 { STATCOL_GPU_P1,"STATCOL_GPU_P1" },
92 { STATCOL_GPU_P2,"STATCOL_GPU_P2" },
93 { STATCOL_BB2D_P1,"STATCOL_BB2D_P1" },
94 { STATCOL_DSS,"STATCOL_DSS" },
95 { STATCOL_CSI2_2,"STATCOL_CSI2_2" },
96 { STATCOL_MMU2,"STATCOL_MMU2" },
97 { STATCOL_IPU1,"STATCOL_IPU1" },
98 { STATCOL_IPU2,"STATCOL_IPU2" },
99 { STATCOL_DMA_SYSTEM_RD,"STATCOL_DMA_SYSTEM_RD" },
100 { STATCOL_DMA_SYSTEM_WR,"STATCOL_DMA_SYSTEM_WR" },
101 { STATCOL_CSI2_1,"STATCOL_CSI2_1" },
102 { STATCOL_USB3_SS,"STATCOL_USB3_SS" },
103 { STATCOL_USB2_SS,"STATCOL_USB2_SS" },
104 { STATCOL_USB2_ULPI_SS1,"STATCOL_USB2_ULPI_SS1" },
105 { STATCOL_USB2_ULPI_SS2,"STATCOL_USB2_ULPI_SS2" },
106 { STATCOL_PCIE_SS1,"STATCOL_PCIE_SS1" },
107 { STATCOL_PCIE_SS2,"STATCOL_PCIE_SS2" },
108 { STATCOL_DSP1_CFG,"STATCOL_DSP1_CFG" },
109 { STATCOL_DSP2_CFG,"STATCOL_DSP2_CFG" },
110 { STATCOL_GMAC_SW,"STATCOL_GMAC_SW" },
111 { STATCOL_PRUSS1_P1,"STATCOL_PRUSS1_P1" },
112 { STATCOL_PRUSS1_P2,"STATCOL_PRUSS1_P2" },
113 { STATCOL_PRUSS2_P1,"STATCOL_PRUSS2_P1" },
114 { STATCOL_PRUSS2_P2,"STATCOL_PRUSS2_P2" },
115 { STATCOL_DMA_CRYPTO_RD,"STATCOL_DMA_CRYPTO_RD" },
116 { STATCOL_DMA_CRYPTO_WR,"STATCOL_DMA_CRYPTO_WR" },
117 { STATCOL_MPU2,"STATCOL_MPU2" },
118 { STATCOL_MMC1,"STATCOL_MMC1" },
119 { STATCOL_MMC2,"STATCOL_MMC2" },
120 { STATCOL_SATA,"STATCOL_SATA" },
121 { STATCOL_MLBSS,"STATCOL_MLBSS" },
122 { STATCOL_BB2D_P2,"STATCOL_BB2D_P2" },
123 { STATCOL_IEEE1500,"STATCOL_IEEE1500" },
124 { STATCOL_DBG,"STATCOL_DBG" },
125 { STATCOL_VCP1,"STATCOL_VCP1" },
126 { STATCOL_OCMC_RAM1,"STATCOL_OCMC_RAM1" },
127 { STATCOL_OCMC_RAM2,"STATCOL_OCMC_RAM2" },
128 { STATCOL_OCMC_RAM3,"STATCOL_OCMC_RAM3" },
129 { STATCOL_GPMC,"STATCOL_GPMC" },
130 { STATCOL_MCASP1,"STATCOL_MCASP1" },
131 { STATCOL_MCASP2,"STATCOL_MCASP2" },
132 { STATCOL_MCASP3,"STATCOL_MCASP3" },
133 { STATCOL_VCP2, "STATCOL_VCP2" }
134};
135
136StatCollectorObj gStatColState;
137
138static void *statcoll_base_mem;
139static int *l3_3_clkctrl;
140
141static UInt32 *statCountDSS = NULL;
142static UInt32 *statCountIVA = NULL;
143static UInt32 *statCountBB2DP1 = NULL;
144static UInt32 *statCountBB2DP2 = NULL;
145static UInt32 *statCountUSB4 = NULL;
146static UInt32 *statCountSata = NULL;
147static UInt32 *statCountEmif1 = NULL;
148static UInt32 *statCountEmif2 = NULL;
149
150
151static statcoll_initiators_object global_object[STATCOL_MAX];
152UInt32 statCountIdx = 0;
153UInt32 TRACE_SZ = 0;
154
155void statCollectorInit()
156{
157 int index;
158
159 gStatColState.stat0_filter_cnt = 0;
160 gStatColState.stat1_filter_cnt = 0;
161 gStatColState.stat2_filter_cnt = 0;
162 gStatColState.stat3_filter_cnt = 0;
163 gStatColState.stat4_filter_cnt = 0;
164 gStatColState.stat5_filter_cnt = 0;
165 gStatColState.stat6_filter_cnt = 0;
166 gStatColState.stat7_filter_cnt = 0;
167 gStatColState.stat8_filter_cnt = 0;
168 gStatColState.stat9_filter_cnt = 0;
169
170 /*
171 typedef struct
172 {
173 UInt32 b_enabled;
174 char name[100];
175 UInt32 *readings;
176 UInt32 *timestamp;
177 UInt32 counter_id;
178 UInt32 base_address;
179 UInt32 mux_req;
180 }statcoll_initiators_object;
181
182 */
183 for(index=STATCOL_EMIF1_SYS; index < STATCOL_MAX; index++)
184 {
185 global_object[index].b_enabled = 0;
186
187 strcpy(global_object[index].name, initiators[index].name);
188
189 global_object[index].readings = malloc(TRACE_SZ * sizeof(UInt32));
190 memset(global_object[index].readings, 0, TRACE_SZ * sizeof(UInt32));
191
192 global_object[index].timestamp = NULL;
193
194 global_object[index].group_id = 0xFF;
195 global_object[index].counter_id = 0;
196 global_object[index].base_address = 0;
197 global_object[index].mux_req = 0;
198 }
199
200}
201
202void wr_stat_reg(UInt32 address, UInt32 data)
203{
204 UInt32 *mymem = statcoll_base_mem;
205 UInt32 delta = (address - STATCOLL_BASE) / 4;
206#ifndef DUMMY_MODE
207 mymem[delta] = data;
208#else
209 printf("WRITE: Address = 0x%x, Data = 0x%x\n", address, data);
210#endif
211}
212
213UInt32 rd_stat_reg(UInt32 address)
214{
215#ifndef DUMMY_MODE
216 UInt32 *mymem = statcoll_base_mem;
217 UInt32 data;
218 UInt32 delta = (address - STATCOLL_BASE) / 4;
219 data = mymem[delta];
220 return data;
221#else
222 printf("READ: Address = 0x%x\n", address);
223#endif
224}
225
226UInt32 statCollectorControlInitialize(UInt32 instance_id)
227{
228 UInt32 cur_base_address = 0;
229 UInt32 cur_event_mux_req;
230 UInt32 cur_event_mux_resp;
231 UInt32 cur_stat_filter_cnt;
232
233 switch (instance_id)
234 {
235 case STATCOL_EMIF1_SYS:
236 cur_base_address = stat_coll0_base_address;
237 cur_event_mux_req = 0;
238 cur_event_mux_resp = 1;
239 gStatColState.stat0_filter_cnt = gStatColState.stat0_filter_cnt + 1;
240 cur_stat_filter_cnt = gStatColState.stat0_filter_cnt;
241 global_object[instance_id].group_id = 0;
242 break;
243 case STATCOL_EMIF2_SYS:
244 cur_base_address = stat_coll0_base_address;
245 cur_event_mux_req = 2;
246 cur_event_mux_resp = 3;
247 gStatColState.stat0_filter_cnt = gStatColState.stat0_filter_cnt + 1;
248 cur_stat_filter_cnt = gStatColState.stat0_filter_cnt;
249 global_object[instance_id].group_id = 0;
250 break;
251 case STATCOL_MA_MPU_P1:
252 cur_base_address = stat_coll0_base_address;
253 cur_event_mux_req = 4;
254 cur_event_mux_resp = 5;
255 gStatColState.stat0_filter_cnt = gStatColState.stat0_filter_cnt + 1;
256 cur_stat_filter_cnt = gStatColState.stat0_filter_cnt;
257 global_object[instance_id].group_id = 0;
258 break;
259 case STATCOL_MA_MPU_P2:
260 cur_base_address = stat_coll0_base_address;
261 cur_event_mux_req = 6;
262 cur_event_mux_resp = 7;
263 gStatColState.stat0_filter_cnt = gStatColState.stat0_filter_cnt + 1;
264 cur_stat_filter_cnt = gStatColState.stat0_filter_cnt;
265 global_object[instance_id].group_id = 0;
266 break;
267 case STATCOL_MPU1:
268 cur_base_address = stat_coll1_base_address;
269 cur_event_mux_req = 0;
270 cur_event_mux_resp = 1;
271 gStatColState.stat1_filter_cnt = gStatColState.stat1_filter_cnt + 1;
272 cur_stat_filter_cnt = gStatColState.stat1_filter_cnt;
273 global_object[instance_id].group_id = 1;
274 break;
275 case STATCOL_MMU1:
276 cur_base_address = stat_coll1_base_address;
277 cur_event_mux_req = 2;
278 cur_event_mux_resp = 3;
279 gStatColState.stat1_filter_cnt = gStatColState.stat1_filter_cnt + 1;
280 cur_stat_filter_cnt = gStatColState.stat1_filter_cnt;
281 global_object[instance_id].group_id = 1;
282 break;
283 case STATCOL_TPTC_RD1:
284 cur_base_address = stat_coll1_base_address;
285 cur_event_mux_req = 4;
286 cur_event_mux_resp = 5;
287 gStatColState.stat1_filter_cnt = gStatColState.stat1_filter_cnt + 1;
288 cur_stat_filter_cnt = gStatColState.stat1_filter_cnt;
289 global_object[instance_id].group_id = 1;
290 break;
291 case STATCOL_TPTC_WR1:
292 cur_base_address = stat_coll1_base_address;
293 cur_event_mux_req = 6;
294 cur_event_mux_resp = 7;
295 gStatColState.stat1_filter_cnt = gStatColState.stat1_filter_cnt + 1;
296 cur_stat_filter_cnt = gStatColState.stat1_filter_cnt;
297 global_object[instance_id].group_id = 1;
298 break;
299 case STATCOL_TPTC_RD2:
300 cur_base_address = stat_coll1_base_address;
301 cur_event_mux_req = 8;
302 cur_event_mux_resp = 9;
303 gStatColState.stat1_filter_cnt = gStatColState.stat1_filter_cnt + 1;
304 cur_stat_filter_cnt = gStatColState.stat1_filter_cnt;
305 global_object[instance_id].group_id = 1;
306 break;
307 case STATCOL_TPTC_WR2:
308 cur_base_address = stat_coll1_base_address;
309 cur_event_mux_req = 10;
310 cur_event_mux_resp = 11;
311 gStatColState.stat1_filter_cnt = gStatColState.stat1_filter_cnt + 1;
312 cur_stat_filter_cnt = gStatColState.stat1_filter_cnt;
313 global_object[instance_id].group_id = 1;
314 break;
315 case STATCOL_VIP1_P1:
316 cur_base_address = stat_coll2_base_address;
317 cur_event_mux_req = 0;
318 cur_event_mux_resp = 1;
319 gStatColState.stat2_filter_cnt = gStatColState.stat2_filter_cnt + 1;
320 cur_stat_filter_cnt = gStatColState.stat2_filter_cnt;
321 global_object[instance_id].group_id = 2;
322 break;
323 case STATCOL_VIP1_P2:
324 cur_base_address = stat_coll2_base_address;
325 cur_event_mux_req = 2;
326 cur_event_mux_resp = 3;
327 gStatColState.stat2_filter_cnt = gStatColState.stat2_filter_cnt + 1;
328 cur_stat_filter_cnt = gStatColState.stat2_filter_cnt;
329 global_object[instance_id].group_id = 2;
330 break;
331 case STATCOL_VIP2_P1:
332 cur_base_address = stat_coll2_base_address;
333 cur_event_mux_req = 4;
334 cur_event_mux_resp = 5;
335 gStatColState.stat2_filter_cnt = gStatColState.stat2_filter_cnt + 1;
336 cur_stat_filter_cnt = gStatColState.stat2_filter_cnt;
337 global_object[instance_id].group_id = 2;
338 break;
339 case STATCOL_VIP2_P2:
340 cur_base_address = stat_coll2_base_address;
341 cur_event_mux_req = 6;
342 cur_event_mux_resp = 7;
343 gStatColState.stat2_filter_cnt = gStatColState.stat2_filter_cnt + 1;
344 cur_stat_filter_cnt = gStatColState.stat2_filter_cnt;
345 global_object[instance_id].group_id = 2;
346 break;
347 case STATCOL_VIP3_P1:
348 cur_base_address = stat_coll2_base_address;
349 cur_event_mux_req = 8;
350 cur_event_mux_resp = 9;
351 gStatColState.stat2_filter_cnt = gStatColState.stat2_filter_cnt + 1;
352 cur_stat_filter_cnt = gStatColState.stat2_filter_cnt;
353 global_object[instance_id].group_id = 2;
354 break;
355 case STATCOL_VIP3_P2:
356 cur_base_address = stat_coll2_base_address;
357 cur_event_mux_req = 10;
358 cur_event_mux_resp = 11;
359 gStatColState.stat2_filter_cnt = gStatColState.stat2_filter_cnt + 1;
360 cur_stat_filter_cnt = gStatColState.stat2_filter_cnt;
361 global_object[instance_id].group_id = 2;
362 break;
363 case STATCOL_VPE_P1:
364 cur_base_address = stat_coll2_base_address;
365 cur_event_mux_req = 12;
366 cur_event_mux_resp = 13;
367 gStatColState.stat2_filter_cnt = gStatColState.stat2_filter_cnt + 1;
368 cur_stat_filter_cnt = gStatColState.stat2_filter_cnt;
369 global_object[instance_id].group_id = 2;
370 break;
371 case STATCOL_VPE_P2:
372 cur_base_address = stat_coll2_base_address;
373 cur_event_mux_req = 14;
374 cur_event_mux_resp = 15;
375 gStatColState.stat2_filter_cnt = gStatColState.stat2_filter_cnt + 1;
376 cur_stat_filter_cnt = gStatColState.stat2_filter_cnt;
377 global_object[instance_id].group_id = 2;
378 break;
379 case STATCOL_EVE1_TC0:
380 cur_base_address = stat_coll3_base_address;
381 cur_event_mux_req = 0;
382 cur_event_mux_resp = 1;
383 gStatColState.stat3_filter_cnt = gStatColState.stat3_filter_cnt + 1;
384 cur_stat_filter_cnt = gStatColState.stat3_filter_cnt;
385 global_object[instance_id].group_id = 3;
386 break;
387 case STATCOL_EVE1_TC1:
388 cur_base_address = stat_coll3_base_address;
389 cur_event_mux_req = 2;
390 cur_event_mux_resp = 3;
391 gStatColState.stat3_filter_cnt = gStatColState.stat3_filter_cnt + 1;
392 cur_stat_filter_cnt = gStatColState.stat3_filter_cnt;
393 global_object[instance_id].group_id = 3;
394 break;
395 case STATCOL_EVE2_TC0:
396 cur_base_address = stat_coll3_base_address;
397 cur_event_mux_req = 4;
398 cur_event_mux_resp = 5;
399 gStatColState.stat3_filter_cnt = gStatColState.stat3_filter_cnt + 1;
400 cur_stat_filter_cnt = gStatColState.stat3_filter_cnt;
401 global_object[instance_id].group_id = 3;
402 break;
403 case STATCOL_EVE2_TC1:
404 cur_base_address = stat_coll3_base_address;
405 cur_event_mux_req = 6;
406 cur_event_mux_resp = 7;
407 gStatColState.stat3_filter_cnt = gStatColState.stat3_filter_cnt + 1;
408 cur_stat_filter_cnt = gStatColState.stat3_filter_cnt;
409 global_object[instance_id].group_id = 3;
410 break;
411 case STATCOL_EVE3_TC0:
412 cur_base_address = stat_coll3_base_address;
413 cur_event_mux_req = 8;
414 cur_event_mux_resp = 9;
415 gStatColState.stat3_filter_cnt = gStatColState.stat3_filter_cnt + 1;
416 cur_stat_filter_cnt = gStatColState.stat3_filter_cnt;
417 global_object[instance_id].group_id = 3;
418 break;
419 case STATCOL_EVE3_TC1:
420 cur_base_address = stat_coll3_base_address;
421 cur_event_mux_req = 10;
422 cur_event_mux_resp = 11;
423 gStatColState.stat3_filter_cnt = gStatColState.stat3_filter_cnt + 1;
424 cur_stat_filter_cnt = gStatColState.stat3_filter_cnt;
425 global_object[instance_id].group_id = 3;
426 break;
427 case STATCOL_EVE4_TC0:
428 cur_base_address = stat_coll3_base_address;
429 cur_event_mux_req = 12;
430 cur_event_mux_resp = 13;
431 gStatColState.stat3_filter_cnt = gStatColState.stat3_filter_cnt + 1;
432 cur_stat_filter_cnt = gStatColState.stat3_filter_cnt;
433 global_object[instance_id].group_id = 3;
434 break;
435 case STATCOL_EVE4_TC1:
436 cur_base_address = stat_coll3_base_address;
437 cur_event_mux_req = 14;
438 cur_event_mux_resp = 15;
439 gStatColState.stat3_filter_cnt = gStatColState.stat3_filter_cnt + 1;
440 cur_stat_filter_cnt = gStatColState.stat3_filter_cnt;
441 global_object[instance_id].group_id = 3;
442 break;
443 case STATCOL_DSP1_MDMA:
444 cur_base_address = stat_coll4_base_address;
445 cur_event_mux_req = 0;
446 cur_event_mux_resp = 1;
447 gStatColState.stat4_filter_cnt = gStatColState.stat4_filter_cnt + 1;
448 cur_stat_filter_cnt = gStatColState.stat4_filter_cnt;
449 global_object[instance_id].group_id = 4;
450 break;
451 case STATCOL_DSP1_EDMA:
452 cur_base_address = stat_coll4_base_address;
453 cur_event_mux_req = 2;
454 cur_event_mux_resp = 3;
455 gStatColState.stat4_filter_cnt = gStatColState.stat4_filter_cnt + 1;
456 cur_stat_filter_cnt = gStatColState.stat4_filter_cnt;
457 global_object[instance_id].group_id = 4;
458 break;
459 case STATCOL_DSP2_MDMA:
460 cur_base_address = stat_coll4_base_address;
461 cur_event_mux_req = 4;
462 cur_event_mux_resp = 5;
463 gStatColState.stat4_filter_cnt = gStatColState.stat4_filter_cnt + 1;
464 cur_stat_filter_cnt = gStatColState.stat4_filter_cnt;
465 global_object[instance_id].group_id = 4;
466 break;
467 case STATCOL_DSP2_EDMA:
468 cur_base_address = stat_coll4_base_address;
469 cur_event_mux_req = 6;
470 cur_event_mux_resp = 7;
471 gStatColState.stat4_filter_cnt = gStatColState.stat4_filter_cnt + 1;
472 cur_stat_filter_cnt = gStatColState.stat4_filter_cnt;
473 global_object[instance_id].group_id = 4;
474 break;
475 case STATCOL_IVA:
476 cur_base_address = stat_coll4_base_address;
477 cur_event_mux_req = 8;
478 cur_event_mux_resp = 9;
479 gStatColState.stat4_filter_cnt = gStatColState.stat4_filter_cnt + 1;
480 cur_stat_filter_cnt = gStatColState.stat4_filter_cnt;
481 global_object[instance_id].group_id = 4;
482 break;
483 case STATCOL_GPU_P1:
484 cur_base_address = stat_coll4_base_address;
485 cur_event_mux_req = 10;
486 cur_event_mux_resp = 11;
487 gStatColState.stat4_filter_cnt = gStatColState.stat4_filter_cnt + 1;
488 cur_stat_filter_cnt = gStatColState.stat4_filter_cnt;
489 global_object[instance_id].group_id = 4;
490 break;
491 case STATCOL_GPU_P2:
492 cur_base_address = stat_coll4_base_address;
493 cur_event_mux_req = 12;
494 cur_event_mux_resp = 13;
495 gStatColState.stat4_filter_cnt = gStatColState.stat4_filter_cnt + 1;
496 cur_stat_filter_cnt = gStatColState.stat4_filter_cnt;
497 global_object[instance_id].group_id = 4;
498 break;
499 case STATCOL_BB2D_P1:
500 cur_base_address = stat_coll4_base_address;
501 cur_event_mux_req = 14;
502 cur_event_mux_resp = 15;
503 gStatColState.stat4_filter_cnt = gStatColState.stat4_filter_cnt + 1;
504 cur_stat_filter_cnt = gStatColState.stat4_filter_cnt;
505 global_object[instance_id].group_id = 4;
506 break;
507 case STATCOL_DSS:
508 cur_base_address = stat_coll5_base_address;
509 cur_event_mux_req = 0;
510 cur_event_mux_resp = 1;
511 gStatColState.stat5_filter_cnt = gStatColState.stat5_filter_cnt + 1;
512 cur_stat_filter_cnt = gStatColState.stat5_filter_cnt;
513 global_object[instance_id].group_id = 5;
514 break;
515 case STATCOL_CSI2_2:
516 cur_base_address = stat_coll5_base_address;
517 cur_event_mux_req = 2;
518 cur_event_mux_resp = 3;
519 gStatColState.stat5_filter_cnt = gStatColState.stat5_filter_cnt + 1;
520 cur_stat_filter_cnt = gStatColState.stat5_filter_cnt;
521 global_object[instance_id].group_id = 5;
522 break;
523 case STATCOL_MMU2:
524 cur_base_address = stat_coll5_base_address;
525 cur_event_mux_req = 4;
526 cur_event_mux_resp = 5;
527 gStatColState.stat5_filter_cnt = gStatColState.stat5_filter_cnt + 1;
528 cur_stat_filter_cnt = gStatColState.stat5_filter_cnt;
529 global_object[instance_id].group_id = 5;
530 break;
531 case STATCOL_IPU1:
532 cur_base_address = stat_coll5_base_address;
533 cur_event_mux_req = 6;
534 cur_event_mux_resp = 7;
535 gStatColState.stat5_filter_cnt = gStatColState.stat5_filter_cnt + 1;
536 cur_stat_filter_cnt = gStatColState.stat5_filter_cnt;
537 global_object[instance_id].group_id = 5;
538 break;
539 case STATCOL_IPU2:
540 cur_base_address = stat_coll5_base_address;
541 cur_event_mux_req = 8;
542 cur_event_mux_resp = 9;
543 gStatColState.stat5_filter_cnt = gStatColState.stat5_filter_cnt + 1;
544 cur_stat_filter_cnt = gStatColState.stat5_filter_cnt;
545 global_object[instance_id].group_id = 5;
546 break;
547 case STATCOL_DMA_SYSTEM_RD:
548 cur_base_address = stat_coll5_base_address;
549 cur_event_mux_req = 10;
550 cur_event_mux_resp = 11;
551 gStatColState.stat5_filter_cnt = gStatColState.stat5_filter_cnt + 1;
552 cur_stat_filter_cnt = gStatColState.stat5_filter_cnt;
553 global_object[instance_id].group_id = 5;
554 break;
555 case STATCOL_DMA_SYSTEM_WR:
556 cur_base_address = stat_coll5_base_address;
557 cur_event_mux_req = 12;
558 cur_event_mux_resp = 13;
559 gStatColState.stat5_filter_cnt = gStatColState.stat5_filter_cnt + 1;
560 cur_stat_filter_cnt = gStatColState.stat5_filter_cnt;
561 global_object[instance_id].group_id = 5;
562 break;
563 case STATCOL_CSI2_1:
564 cur_base_address = stat_coll5_base_address;
565 cur_event_mux_req = 14;
566 cur_event_mux_resp = 15;
567 gStatColState.stat5_filter_cnt = gStatColState.stat5_filter_cnt + 1;
568 cur_stat_filter_cnt = gStatColState.stat5_filter_cnt;
569 global_object[instance_id].group_id = 5;
570 break;
571 case STATCOL_USB3_SS:
572 cur_base_address = stat_coll6_base_address;
573 cur_event_mux_req = 0;
574 cur_event_mux_resp = 1;
575 gStatColState.stat6_filter_cnt = gStatColState.stat6_filter_cnt + 1;
576 cur_stat_filter_cnt = gStatColState.stat6_filter_cnt;
577 global_object[instance_id].group_id = 6;
578 break;
579 case STATCOL_USB2_SS:
580 cur_base_address = stat_coll6_base_address;
581 cur_event_mux_req = 2;
582 cur_event_mux_resp = 3;
583 gStatColState.stat6_filter_cnt = gStatColState.stat6_filter_cnt + 1;
584 cur_stat_filter_cnt = gStatColState.stat6_filter_cnt;
585 global_object[instance_id].group_id = 6;
586 break;
587 case STATCOL_USB2_ULPI_SS1:
588 cur_base_address = stat_coll6_base_address;
589 cur_event_mux_req = 4;
590 cur_event_mux_resp = 5;
591 gStatColState.stat6_filter_cnt = gStatColState.stat6_filter_cnt + 1;
592 cur_stat_filter_cnt = gStatColState.stat6_filter_cnt;
593 global_object[instance_id].group_id = 6;
594 break;
595 case STATCOL_USB2_ULPI_SS2:
596 cur_base_address = stat_coll6_base_address;
597 cur_event_mux_req = 6;
598 cur_event_mux_resp = 7;
599 gStatColState.stat6_filter_cnt = gStatColState.stat6_filter_cnt + 1;
600 cur_stat_filter_cnt = gStatColState.stat6_filter_cnt;
601 global_object[instance_id].group_id = 6;
602 break;
603 case STATCOL_PCIE_SS1:
604 cur_base_address = stat_coll6_base_address;
605 cur_event_mux_req = 8;
606 cur_event_mux_resp = 9;
607 gStatColState.stat6_filter_cnt = gStatColState.stat6_filter_cnt + 1;
608 cur_stat_filter_cnt = gStatColState.stat6_filter_cnt;
609 global_object[instance_id].group_id = 6;
610 break;
611 case STATCOL_PCIE_SS2:
612 cur_base_address = stat_coll6_base_address;
613 cur_event_mux_req = 10;
614 cur_event_mux_resp = 11;
615 gStatColState.stat6_filter_cnt = gStatColState.stat6_filter_cnt + 1;
616 cur_stat_filter_cnt = gStatColState.stat6_filter_cnt;
617 global_object[instance_id].group_id = 6;
618 break;
619 case STATCOL_DSP1_CFG:
620 cur_base_address = stat_coll6_base_address;
621 cur_event_mux_req = 12;
622 cur_event_mux_resp = 13;
623 gStatColState.stat6_filter_cnt = gStatColState.stat6_filter_cnt + 1;
624 cur_stat_filter_cnt = gStatColState.stat6_filter_cnt;
625 global_object[instance_id].group_id = 6;
626 break;
627 case STATCOL_DSP2_CFG:
628 cur_base_address = stat_coll6_base_address;
629 cur_event_mux_req = 14;
630 cur_event_mux_resp = 15;
631 gStatColState.stat6_filter_cnt = gStatColState.stat6_filter_cnt + 1;
632 cur_stat_filter_cnt = gStatColState.stat6_filter_cnt;
633 global_object[instance_id].group_id = 6;
634 break;
635 case STATCOL_GMAC_SW:
636 cur_base_address = stat_coll7_base_address;
637 cur_event_mux_req = 0;
638 cur_event_mux_resp = 1;
639 gStatColState.stat7_filter_cnt = gStatColState.stat7_filter_cnt + 1;
640 cur_stat_filter_cnt = gStatColState.stat7_filter_cnt;
641 global_object[instance_id].group_id = 7;
642 break;
643 case STATCOL_PRUSS1_P1:
644 cur_base_address = stat_coll7_base_address;
645 cur_event_mux_req = 2;
646 cur_event_mux_resp = 3;
647 gStatColState.stat7_filter_cnt = gStatColState.stat7_filter_cnt + 1;
648 cur_stat_filter_cnt = gStatColState.stat7_filter_cnt;
649 global_object[instance_id].group_id = 7;
650 break;
651 case STATCOL_PRUSS1_P2:
652 cur_base_address = stat_coll7_base_address;
653 cur_event_mux_req = 4;
654 cur_event_mux_resp = 5;
655 gStatColState.stat7_filter_cnt = gStatColState.stat7_filter_cnt + 1;
656 cur_stat_filter_cnt = gStatColState.stat7_filter_cnt;
657 global_object[instance_id].group_id = 7;
658 break;
659 case STATCOL_PRUSS2_P1:
660 cur_base_address = stat_coll7_base_address;
661 cur_event_mux_req = 6;
662 cur_event_mux_resp = 7;
663 gStatColState.stat7_filter_cnt = gStatColState.stat7_filter_cnt + 1;
664 cur_stat_filter_cnt = gStatColState.stat7_filter_cnt;
665 global_object[instance_id].group_id = 7;
666 break;
667 case STATCOL_PRUSS2_P2:
668 cur_base_address = stat_coll7_base_address;
669 cur_event_mux_req = 8;
670 cur_event_mux_resp = 9;
671 gStatColState.stat7_filter_cnt = gStatColState.stat7_filter_cnt + 1;
672 cur_stat_filter_cnt = gStatColState.stat7_filter_cnt;
673 global_object[instance_id].group_id = 7;
674 break;
675 case STATCOL_DMA_CRYPTO_RD:
676 cur_base_address = stat_coll7_base_address;
677 cur_event_mux_req = 10;
678 cur_event_mux_resp = 11;
679 gStatColState.stat7_filter_cnt = gStatColState.stat7_filter_cnt + 1;
680 cur_stat_filter_cnt = gStatColState.stat7_filter_cnt;
681 global_object[instance_id].group_id = 7;
682 break;
683 case STATCOL_DMA_CRYPTO_WR:
684 cur_base_address = stat_coll7_base_address;
685 cur_event_mux_req = 12;
686 cur_event_mux_resp = 13;
687 gStatColState.stat7_filter_cnt = gStatColState.stat7_filter_cnt + 1;
688 cur_stat_filter_cnt = gStatColState.stat7_filter_cnt;
689 global_object[instance_id].group_id = 7;
690 break;
691 case STATCOL_MPU2:
692 cur_base_address = stat_coll7_base_address;
693 cur_event_mux_req = 14;
694 cur_event_mux_resp = 15;
695 gStatColState.stat7_filter_cnt = gStatColState.stat7_filter_cnt + 1;
696 cur_stat_filter_cnt = gStatColState.stat7_filter_cnt;
697 global_object[instance_id].group_id = 7;
698 break;
699 case STATCOL_MMC1:
700 cur_base_address = stat_coll8_base_address;
701 cur_event_mux_req = 0;
702 cur_event_mux_resp = 1;
703 gStatColState.stat8_filter_cnt = gStatColState.stat8_filter_cnt + 1;
704 cur_stat_filter_cnt = gStatColState.stat8_filter_cnt;
705 global_object[instance_id].group_id = 8;
706 break;
707 case STATCOL_MMC2:
708 cur_base_address = stat_coll8_base_address;
709 cur_event_mux_req = 2;
710 cur_event_mux_resp = 3;
711 gStatColState.stat8_filter_cnt = gStatColState.stat8_filter_cnt + 1;
712 cur_stat_filter_cnt = gStatColState.stat8_filter_cnt;
713 global_object[instance_id].group_id = 8;
714 break;
715 case STATCOL_SATA:
716 cur_base_address = stat_coll8_base_address;
717 cur_event_mux_req = 4;
718 cur_event_mux_resp = 5;
719 gStatColState.stat8_filter_cnt = gStatColState.stat8_filter_cnt + 1;
720 cur_stat_filter_cnt = gStatColState.stat8_filter_cnt;
721 global_object[instance_id].group_id = 8;
722 break;
723 case STATCOL_MLBSS:
724 cur_base_address = stat_coll8_base_address;
725 cur_event_mux_req = 6;
726 cur_event_mux_resp = 7;
727 gStatColState.stat8_filter_cnt = gStatColState.stat8_filter_cnt + 1;
728 cur_stat_filter_cnt = gStatColState.stat8_filter_cnt;
729 global_object[instance_id].group_id = 8;
730 break;
731 case STATCOL_BB2D_P2:
732 cur_base_address = stat_coll8_base_address;
733 cur_event_mux_req = 8;
734 cur_event_mux_resp = 9;
735 gStatColState.stat8_filter_cnt = gStatColState.stat8_filter_cnt + 1;
736 cur_stat_filter_cnt = gStatColState.stat8_filter_cnt;
737 global_object[instance_id].group_id = 8;
738 break;
739 case STATCOL_IEEE1500:
740 cur_base_address = stat_coll8_base_address;
741 cur_event_mux_req = 10;
742 cur_event_mux_resp = 11;
743 gStatColState.stat8_filter_cnt = gStatColState.stat8_filter_cnt + 1;
744 cur_stat_filter_cnt = gStatColState.stat8_filter_cnt;
745 global_object[instance_id].group_id = 8;
746 break;
747 case STATCOL_DBG:
748 cur_base_address = stat_coll8_base_address;
749 cur_event_mux_req = 12;
750 cur_event_mux_resp = 13;
751 gStatColState.stat8_filter_cnt = gStatColState.stat8_filter_cnt + 1;
752 cur_stat_filter_cnt = gStatColState.stat8_filter_cnt;
753 global_object[instance_id].group_id = 8;
754 break;
755 case STATCOL_VCP1:
756 cur_base_address = stat_coll8_base_address;
757 cur_event_mux_req = 14;
758 cur_event_mux_resp = 15;
759 gStatColState.stat8_filter_cnt = gStatColState.stat8_filter_cnt + 1;
760 cur_stat_filter_cnt = gStatColState.stat8_filter_cnt;
761 global_object[instance_id].group_id = 8;
762 break;
763 case STATCOL_OCMC_RAM1:
764 cur_base_address = stat_coll9_base_address;
765 cur_event_mux_req = 0;
766 cur_event_mux_resp = 1;
767 gStatColState.stat9_filter_cnt = gStatColState.stat9_filter_cnt + 1;
768 cur_stat_filter_cnt = gStatColState.stat9_filter_cnt;
769 global_object[instance_id].group_id = 9;
770 break;
771 case STATCOL_OCMC_RAM2:
772 cur_base_address = stat_coll9_base_address;
773 cur_event_mux_req = 2;
774 cur_event_mux_resp = 3;
775 gStatColState.stat9_filter_cnt = gStatColState.stat9_filter_cnt + 1;
776 cur_stat_filter_cnt = gStatColState.stat9_filter_cnt;
777 global_object[instance_id].group_id = 9;
778 break;
779 case STATCOL_OCMC_RAM3:
780 cur_base_address = stat_coll9_base_address;
781 cur_event_mux_req = 4;
782 cur_event_mux_resp = 5;
783 gStatColState.stat9_filter_cnt = gStatColState.stat9_filter_cnt + 1;
784 cur_stat_filter_cnt = gStatColState.stat9_filter_cnt;
785 global_object[instance_id].group_id = 9;
786 break;
787 case STATCOL_GPMC:
788 cur_base_address = stat_coll9_base_address;
789 cur_event_mux_req = 6;
790 cur_event_mux_resp = 7;
791 gStatColState.stat9_filter_cnt = gStatColState.stat9_filter_cnt + 1;
792 cur_stat_filter_cnt = gStatColState.stat9_filter_cnt;
793 global_object[instance_id].group_id = 9;
794 break;
795 case STATCOL_MCASP1:
796 cur_base_address = stat_coll9_base_address;
797 cur_event_mux_req = 8;
798 cur_event_mux_resp = 9;
799 gStatColState.stat9_filter_cnt = gStatColState.stat9_filter_cnt + 1;
800 cur_stat_filter_cnt = gStatColState.stat9_filter_cnt;
801 global_object[instance_id].group_id = 9;
802 break;
803 case STATCOL_MCASP2:
804 cur_base_address = stat_coll9_base_address;
805 cur_event_mux_req = 10;
806 cur_event_mux_resp = 11;
807 gStatColState.stat9_filter_cnt = gStatColState.stat9_filter_cnt + 1;
808 cur_stat_filter_cnt = gStatColState.stat9_filter_cnt;
809 global_object[instance_id].group_id = 9;
810 break;
811 case STATCOL_MCASP3:
812 cur_base_address = stat_coll9_base_address;
813 cur_event_mux_req = 12;
814 cur_event_mux_resp = 13;
815 gStatColState.stat9_filter_cnt = gStatColState.stat9_filter_cnt + 1;
816 cur_stat_filter_cnt = gStatColState.stat9_filter_cnt;
817 global_object[instance_id].group_id = 9;
818 break;
819 case STATCOL_VCP2:
820 cur_base_address = stat_coll9_base_address;
821 cur_event_mux_req = 14;
822 cur_event_mux_resp = 15;
823 gStatColState.stat9_filter_cnt = gStatColState.stat9_filter_cnt + 1;
824 cur_stat_filter_cnt = gStatColState.stat9_filter_cnt;
825 global_object[instance_id].group_id = 9;
826 break;
827 default:
828 printf("ERROR: Unknown initiator\n");
829 exit(0);
830 };
831
832 {
833 if ( cur_stat_filter_cnt > 4 )
834 {
835 printf("WARNING: We have exhausted filters/counters.....\n");
836 return 0;
837 }
838 // Global Enable Stat Collector
839 wr_stat_reg(cur_base_address+0x8,0x1);
840
841 // Soft Enable Stat Collector
842 wr_stat_reg(cur_base_address+0xC,0x1);
843
844 wr_stat_reg(cur_base_address+0x18,0x5);
845 // Operation of Stat Collector / RespEvt => Packet
846 wr_stat_reg(cur_base_address+0x1C,0x5);
847
848
849 // Event Sel
850 wr_stat_reg(cur_base_address+0x20+4*(cur_stat_filter_cnt-1),cur_event_mux_req);
851
852 // Op is EventInfo
853 wr_stat_reg(cur_base_address+0x1FC+(0x158*(cur_stat_filter_cnt-1)),2);
854
855 // Event Info Sel Op -> packet length
856 wr_stat_reg(cur_base_address+0x1F8+(0x158*(cur_stat_filter_cnt-1)),0);
857
858 // Filter Global Enable
859 wr_stat_reg(cur_base_address+0xAC+(0x158*(cur_stat_filter_cnt-1)),0x1);
860
861 // Filter Enable
862 wr_stat_reg(cur_base_address+0xBC+(0x158*(cur_stat_filter_cnt-1)),0x1);
863
864 // Manual dump
865 wr_stat_reg(cur_base_address+0x54,0x1);
866 // use send register to reset counters
867
868 }
869
870 global_object[instance_id].mux_req = cur_event_mux_req;
871 global_object[instance_id].base_address = cur_base_address;
872 global_object[instance_id].counter_id = cur_stat_filter_cnt;
873 global_object[instance_id].b_enabled = 1;
874
875 return cur_stat_filter_cnt;
876}
877
878
879
880void statCollectorReadGroup(UInt32 group_id)
881{
882 int i=0;
883 UInt32 cur_base_address = 0x45001000 + ((group_id - 1) * 0x1000);
884
885 wr_stat_reg(cur_base_address+0xC,0x0);
886
887 for(i=0; i < STATCOL_MAX; i++)
888 {
889 if(global_object[i].group_id == (group_id - 1) &&
890 global_object[i].b_enabled == 1)
891 {
892 UInt32 cur_stat_filter_cnt = global_object[i].counter_id;
893
894 global_object[i].readings[statCountIdx] = rd_stat_reg(cur_base_address+0x8C+((cur_stat_filter_cnt-1)*4));
895 }
896 }
897
898 wr_stat_reg(cur_base_address+0xC,0x1);
899}
900
901
902UInt32 statcoll_start(UInt32 TOTAL_TIME, UInt32 INTERVAL_US, char list[][50])
903{
904 int i, fd, index;
905 UInt32 counterIdDss, counterIdIva, counterIdBB2dP1, counterIdBB2dP2, counterIdUsb4, counterIdSata, counterIdEmif1, counterIdEmif2;
906
907
908 struct timeval tv1, tv2;
909 gettimeofday(&tv1, NULL);
910 printf("------------------------------------------------\n");
911 printf("Compile time = %s %s\n",__DATE__, __TIME__);
912 printf("------------------------------------------------\n\n");
913 //printd("Start time = %d\n", time(NULL));
914 //printd("Time seconds = %d, usecs = %d\n", tv.tv_sec, tv.tv_usec);
915
916 statcoll_params params;
917 memset(&params, sizeof(params), 0);
918 params.INTERVAL_US = INTERVAL_US;
919 params.TOTAL_TIME = TOTAL_TIME;
920
921 i=0;
922 index=0;
923 while(list[i][0] != 0)
924 {
925 for(index=0; index< STATCOL_MAX; index++) {
926 if(strcmp(list[i], initiators[index].name) == 0)
927 {
928 strcpy(params.user_config_list[params.no_of_initiators].name, list[i]);
929 params.user_config_list[params.no_of_initiators++].id = initiators[index].id;
930 break;
931 }
932 }
933
934 if(index == STATCOL_MAX) {
935 printf("ERROR: Unknown initiator \n");
936 exit(0);
937 }
938 i++;
939 }
940
941 printf("Total configured initiators = %d\n", params.no_of_initiators);
942
943
944 fd = open("/dev/mem", O_RDWR);
945 if (fd == -1){
946 printf("error fd=open() \n");
947 return -1;
948 }
949 statcoll_base_mem = mmap(NULL, STATCOLL_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, STATCOLL_BASE);
950
951 if (statcoll_base_mem == MAP_FAILED){
952 printf("ERROR: mmap failed \n");
953 return;
954 }
955 close(fd);
956
957 fd = open("/dev/mem", O_RDWR);
958 if (fd == -1){
959 printf("error fd=open() \n");
960 return -1;
961 }
962 l3_3_clkctrl = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, CM_L3INSTR_REGISTER_BASE);
963 if (l3_3_clkctrl == MAP_FAILED){
964 printf("ERROR: mmap failed for CM_L3INSTR_REGISTER_BASE\n");
965 return;
966 }
967 close(fd);
968
969 printf("SUCCESS: Mapped 0x%x to user space address 0x%x\n", STATCOLL_BASE, statcoll_base_mem);
970 printf("INTERVAL = %d usecs\n", INTERVAL_US);
971 printf("TOTAL TIME = %d seconds\n", TOTAL_TIME);
972 TRACE_SZ = (TOTAL_TIME * 1000000)/INTERVAL_US;
973 printf("TRACE SIZE = %d samples\n", TRACE_SZ);
974
975 printf("**************************************\n");
976 printf("Going to initialize the L3 clocks \n");
977 l3_3_clkctrl[CM_L3INSTR_L3INSTR_CLKSTCTRL_OFFSET >> 2] = 0x2;
978 l3_3_clkctrl[CM_L3INSTR_L3_MAIN_2_CLKCTRL_OFFSET >> 2] = 0x1;
979 printf("**************************************\n");
980
981 while( (l3_3_clkctrl[CM_L3INSTR_L3_MAIN_2_CLKCTRL_OFFSET >> 2] & 0x30000) != 0x0)
982 {
983 printf("Waiting on module to be functional\n");
984 }
985
986 statCollectorInit();
987
988 printf("SUCCESS: Initialized STAT COLLECTOR\n");
989 /* Initialize all enabled initiators */
990 for(index =0; index < params.no_of_initiators; index++) {
991 printf("\t\t Initialized %s\n", params.user_config_list[index].name);
992 statCollectorControlInitialize(params.user_config_list[index].id);
993 }
994
995 while(statCountIdx != (TRACE_SZ - 1))
996 {
997 usleep(INTERVAL_US);
998 int group;
999 for(group = 1; group<11; group++)
1000 statCollectorReadGroup(group);
1001
1002 statCountIdx++;
1003 }
1004
1005 printf("------------------------------------------------\n\n");
1006 printf("SUCCESS: Stat collection completed... Writing into file now\n");
1007 FILE *outfile = fopen("statcollector.csv", "w+");
1008 if (!outfile) {
1009 printf("\n ERROR: Error opening file");
1010 }
1011
1012 /* Ignore the first index at 0 */
1013 for(index=1; index<statCountIdx; index++) {
1014 for(i=0; i<params.no_of_initiators; i++) {
1015 fprintf(outfile,"%s = %d,", params.user_config_list[i].name, global_object[params.user_config_list[i].id].readings[index]);
1016 }
1017 fprintf(outfile,"\n");
1018 }
1019 fclose(outfile);
1020
1021 gettimeofday(&tv2, NULL);
1022 //printf("End time = %d\n", time(NULL));
1023 //printf("Time seconds = %d, usecs = %d\n", tv.tv_sec, tv.tv_usec);
1024 printf("Total execution time = %d secs, %d usecs\n\n", (tv2.tv_sec - tv1.tv_sec), (tv2.tv_usec - tv2.tv_usec));
1025
1026 return 0;
1027}
1028
1029
diff --git a/bandwidth-tool/statcoll.h b/bandwidth-tool/statcoll.h
new file mode 100644
index 0000000..fa92753
--- /dev/null
+++ b/bandwidth-tool/statcoll.h
@@ -0,0 +1,152 @@
1#ifndef __STATCOLL_H
2#define __STATCOLL_H
3
4
5#define CM_L3INSTR_REGISTER_BASE (0x4A008000)
6
7#define CM_L3INSTR_L3INSTR_CLKSTCTRL_OFFSET (0xE00)
8#define CM_L3INSTR_L3_MAIN_2_CLKCTRL_OFFSET (0xE20)
9
10#define STATCOLL_SIZE 40960
11#define STATCOLL_BASE (0x45001000)
12
13#define stat_coll0_base_address (0x45001000)
14#define stat_coll1_base_address (0x45002000)
15#define stat_coll2_base_address (0x45003000)
16#define stat_coll3_base_address (0x45004000)
17#define stat_coll4_base_address (0x45005000)
18#define stat_coll5_base_address (0x45006000)
19#define stat_coll6_base_address (0x45007000)
20#define stat_coll7_base_address (0x45008000)
21#define stat_coll8_base_address (0x45009000)
22#define stat_coll9_base_address (0x4500a000)
23
24#define printd(fmt, ...) \
25 do { if (debug) fprintf(stderr, fmt, __VA_ARGS__); } while (0)
26
27typedef unsigned int UInt32;
28
29
30typedef enum
31{
32 STATCOL_EMIF1_SYS,
33 STATCOL_EMIF2_SYS,
34 STATCOL_MA_MPU_P1,
35 STATCOL_MA_MPU_P2,
36 STATCOL_MPU1,
37 STATCOL_MMU1,
38 STATCOL_TPTC_RD1,
39 STATCOL_TPTC_WR1,
40 STATCOL_TPTC_RD2,
41 STATCOL_TPTC_WR2,
42 STATCOL_VIP1_P1,
43 STATCOL_VIP1_P2,
44 STATCOL_VIP2_P1,
45 STATCOL_VIP2_P2,
46 STATCOL_VIP3_P1,
47 STATCOL_VIP3_P2,
48 STATCOL_VPE_P1,
49 STATCOL_VPE_P2,
50 STATCOL_EVE1_TC0,
51 STATCOL_EVE1_TC1,
52 STATCOL_EVE2_TC0,
53 STATCOL_EVE2_TC1,
54 STATCOL_EVE3_TC0,
55 STATCOL_EVE3_TC1,
56 STATCOL_EVE4_TC0,
57 STATCOL_EVE4_TC1,
58 STATCOL_DSP1_MDMA,
59 STATCOL_DSP1_EDMA,
60 STATCOL_DSP2_MDMA,
61 STATCOL_DSP2_EDMA,
62 STATCOL_IVA,
63 STATCOL_GPU_P1,
64 STATCOL_GPU_P2,
65 STATCOL_BB2D_P1,
66 STATCOL_DSS,
67 STATCOL_CSI2_2,
68 STATCOL_MMU2,
69 STATCOL_IPU1,
70 STATCOL_IPU2,
71 STATCOL_DMA_SYSTEM_RD,
72 STATCOL_DMA_SYSTEM_WR,
73 STATCOL_CSI2_1,
74 STATCOL_USB3_SS,
75 STATCOL_USB2_SS,
76 STATCOL_USB2_ULPI_SS1,
77 STATCOL_USB2_ULPI_SS2,
78 STATCOL_PCIE_SS1,
79 STATCOL_PCIE_SS2,
80 STATCOL_DSP1_CFG,
81 STATCOL_DSP2_CFG,
82 STATCOL_GMAC_SW,
83 STATCOL_PRUSS1_P1,
84 STATCOL_PRUSS1_P2,
85 STATCOL_PRUSS2_P1,
86 STATCOL_PRUSS2_P2,
87 STATCOL_DMA_CRYPTO_RD,
88 STATCOL_DMA_CRYPTO_WR,
89 STATCOL_MPU2,
90 STATCOL_MMC1,
91 STATCOL_MMC2,
92 STATCOL_SATA,
93 STATCOL_MLBSS,
94 STATCOL_BB2D_P2,
95 STATCOL_IEEE1500,
96 STATCOL_DBG,
97 STATCOL_VCP1,
98 STATCOL_OCMC_RAM1,
99 STATCOL_OCMC_RAM2,
100 STATCOL_OCMC_RAM3,
101 STATCOL_GPMC,
102 STATCOL_MCASP1,
103 STATCOL_MCASP2,
104 STATCOL_MCASP3,
105 STATCOL_VCP2,
106 STATCOL_MAX
107} STATCOL_ID;
108
109
110
111typedef struct
112{
113 UInt32 stat0_filter_cnt;
114 UInt32 stat1_filter_cnt;
115 UInt32 stat2_filter_cnt;
116 UInt32 stat3_filter_cnt;
117 UInt32 stat4_filter_cnt;
118 UInt32 stat5_filter_cnt;
119 UInt32 stat6_filter_cnt;
120 UInt32 stat7_filter_cnt;
121 UInt32 stat8_filter_cnt;
122 UInt32 stat9_filter_cnt;
123} StatCollectorObj;
124
125struct list_of_initiators
126{
127 STATCOL_ID id;
128 char name[50];
129};
130
131typedef struct
132{
133 UInt32 INTERVAL_US;
134 UInt32 TOTAL_TIME;
135 UInt32 no_of_initiators;
136 struct list_of_initiators user_config_list[STATCOL_MAX];
137} statcoll_params;
138
139typedef struct
140{
141 UInt32 b_enabled;
142 char name[100];
143 UInt32 *readings;
144 UInt32 *timestamp;
145 UInt32 group_id;
146 UInt32 counter_id;
147 UInt32 base_address;
148 UInt32 mux_req;
149}statcoll_initiators_object;
150
151
152#endif
diff --git a/configure.ac b/configure.ac
index a3352d1..82f159e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,5 +67,5 @@ fi
67 67
68# Checks for library functions. 68# Checks for library functions.
69 69
70AC_CONFIG_FILES([Makefile vpe/Makefile vip/Makefile drm-tests/Makefile thermal/Makefile messageq/messageq_ipc_linux/Makefile gst/Makefile]) 70AC_CONFIG_FILES([Makefile vpe/Makefile vip/Makefile drm-tests/Makefile thermal/Makefile messageq/messageq_ipc_linux/Makefile gst/Makefile bandwidth-tool/Makefile])
71AC_OUTPUT 71AC_OUTPUT