This source file includes following definitions.
- bufs_init
- bufs_cmp
- bufs_confirm
- bman_test_api
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 #include "bman_test.h"
32
33 #define NUM_BUFS 93
34 #define LOOPS 3
35 #define BMAN_TOKEN_MASK 0x00FFFFFFFFFFLLU
36
37 static struct bman_pool *pool;
38 static struct bm_buffer bufs_in[NUM_BUFS] ____cacheline_aligned;
39 static struct bm_buffer bufs_out[NUM_BUFS] ____cacheline_aligned;
40 static int bufs_received;
41
42 static void bufs_init(void)
43 {
44 int i;
45
46 for (i = 0; i < NUM_BUFS; i++)
47 bm_buffer_set64(&bufs_in[i], 0xfedc01234567LLU * i);
48 bufs_received = 0;
49 }
50
51 static inline int bufs_cmp(const struct bm_buffer *a, const struct bm_buffer *b)
52 {
53 if (bman_ip_rev == BMAN_REV20 || bman_ip_rev == BMAN_REV21) {
54
55
56
57
58
59
60
61
62
63
64
65
66 if ((bm_buffer_get64(a) & BMAN_TOKEN_MASK) <
67 (bm_buffer_get64(b) & BMAN_TOKEN_MASK))
68 return -1;
69 if ((bm_buffer_get64(a) & BMAN_TOKEN_MASK) >
70 (bm_buffer_get64(b) & BMAN_TOKEN_MASK))
71 return 1;
72 } else {
73 if (bm_buffer_get64(a) < bm_buffer_get64(b))
74 return -1;
75 if (bm_buffer_get64(a) > bm_buffer_get64(b))
76 return 1;
77 }
78
79 return 0;
80 }
81
82 static void bufs_confirm(void)
83 {
84 int i, j;
85
86 for (i = 0; i < NUM_BUFS; i++) {
87 int matches = 0;
88
89 for (j = 0; j < NUM_BUFS; j++)
90 if (!bufs_cmp(&bufs_in[i], &bufs_out[j]))
91 matches++;
92 WARN_ON(matches != 1);
93 }
94 }
95
96
97 void bman_test_api(void)
98 {
99 int i, loops = LOOPS;
100
101 bufs_init();
102
103 pr_info("%s(): Starting\n", __func__);
104
105 pool = bman_new_pool();
106 if (!pool) {
107 pr_crit("bman_new_pool() failed\n");
108 goto failed;
109 }
110
111
112 do_loop:
113 i = 0;
114 while (i < NUM_BUFS) {
115 int num = 8;
116
117 if (i + num > NUM_BUFS)
118 num = NUM_BUFS - i;
119 if (bman_release(pool, bufs_in + i, num)) {
120 pr_crit("bman_release() failed\n");
121 goto failed;
122 }
123 i += num;
124 }
125
126
127 while (i > 0) {
128 int tmp, num = 8;
129
130 if (num > i)
131 num = i;
132 tmp = bman_acquire(pool, bufs_out + i - num, num);
133 WARN_ON(tmp != num);
134 i -= num;
135 }
136 i = bman_acquire(pool, NULL, 1);
137 WARN_ON(i > 0);
138
139 bufs_confirm();
140
141 if (--loops)
142 goto do_loop;
143
144
145 bman_free_pool(pool);
146 pr_info("%s(): Finished\n", __func__);
147 return;
148
149 failed:
150 WARN_ON(1);
151 }