1 /*
2 * Copyright 2023-2024 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8 #include "mem_pool_config.h"
9
10 #if CONFIG_MEM_POOLS
11
12 #define ALIGNED_START(x)
13
14 /******************************** Pool ID 0 ********************************/
15 // Pool 0 buffer pool sizes and buffer counts
16 #define POOL_ID0_BLOCK_POOL_CNT 1
17
18 // Buffer 0
19
20 #define POOL_ID0_BUF0_CNT 1
21
22 /* Buffer descriptor size already part of TX size so don't add again */
23 #define POOL_ID0_BUF0_SZ 1500
24
25 // Pool 0 total buffer size calculation
26 #define POOL_ID0_SZ (POOL_ID0_BUF0_SZ * POOL_ID0_BUF0_CNT)
27
28 // Pool 0 block pool pointer overhead calculation
29 #define POOL_ID0_OVERHEAD ((POOL_ID0_BUF0_CNT)*POOL_OVERHEAD)
30
31 // Pool 0 total pool size calculation
32 #define POOL_ID0_POOL_SZ (POOL_ID0_SZ + POOL_ID0_OVERHEAD)
33
34 /******************************** Pool ID 1 ********************************/
35 // Pool 1 buffer pool sizes and buffer counts
36 #define POOL_ID1_BLOCK_POOL_CNT 1
37
38 // Buffer 0
39
40 #define POOL_ID1_BUF0_CNT 2
41
42 /* Buffer descriptor size already part of TX size so don't add again */
43 #define POOL_ID1_BUF0_SZ 4600
44
45 // Pool 1 total buffer size calculation
46 #define POOL_ID1_SZ (POOL_ID1_BUF0_SZ * POOL_ID1_BUF0_CNT)
47
48 // Pool 1 block pool pointer overhead calculation
49 #define POOL_ID1_OVERHEAD ((POOL_ID1_BUF0_CNT)*POOL_OVERHEAD)
50
51 // Pool 1 total pool size calculation
52 #define POOL_ID1_POOL_SZ (POOL_ID1_SZ + POOL_ID1_OVERHEAD)
53
54 /******************************** Pool ID 2 ********************************/
55 // Pool 2 buffer pool sizes and buffer counts
56 #define POOL_ID2_BLOCK_POOL_CNT 1
57
58 // Buffer 0
59
60 #define POOL_ID2_BUF0_CNT 128
61
62 /* Buffer descriptor size already part of TX size so don't add again */
63 #define POOL_ID2_BUF0_SZ 32
64
65 // Pool 2 total buffer size calculation
66 #define POOL_ID2_SZ (POOL_ID2_BUF0_SZ * POOL_ID2_BUF0_CNT)
67
68 // Pool 2 block pool pointer overhead calculation
69 #define POOL_ID2_OVERHEAD ((POOL_ID2_BUF0_CNT)*POOL_OVERHEAD)
70
71 // Pool 2 total pool size calculation
72 #define POOL_ID2_POOL_SZ (POOL_ID2_SZ + POOL_ID2_OVERHEAD)
73
74 /******************************** Pool ID 3 ********************************/
75 // Pool 3 buffer pool sizes and buffer counts
76 #define POOL_ID3_BLOCK_POOL_CNT 1
77
78 // Buffer 0
79
80 #define POOL_ID3_BUF0_CNT 256
81
82 /* Buffer descriptor size already part of TX size so don't add again */
83 #define POOL_ID3_BUF0_SZ 128
84
85 // Pool 3 total buffer size calculation
86 #define POOL_ID3_SZ (POOL_ID3_BUF0_SZ * POOL_ID3_BUF0_CNT)
87
88 // Pool 3 block pool pointer overhead calculation
89 #define POOL_ID3_OVERHEAD ((POOL_ID3_BUF0_CNT)*POOL_OVERHEAD)
90
91 // Pool 3 total pool size calculation
92 #define POOL_ID3_POOL_SZ (POOL_ID3_SZ + POOL_ID3_OVERHEAD)
93
94 /******************************** Pool ID 4 ********************************/
95 // Pool 4 buffer pool sizes and buffer counts
96 #define POOL_ID4_BLOCK_POOL_CNT 1
97
98 // Buffer 0
99
100 #define POOL_ID4_BUF0_CNT 4
101
102 /* Buffer descriptor size already part of TX size so don't add again */
103 #define POOL_ID4_BUF0_SZ 256
104
105 // Pool 4 total buffer size calculation
106 #define POOL_ID4_SZ (POOL_ID4_BUF0_SZ * POOL_ID4_BUF0_CNT)
107
108 // Pool 4 block pool pointer overhead calculation
109 #define POOL_ID4_OVERHEAD ((POOL_ID4_BUF0_CNT)*POOL_OVERHEAD)
110
111 // Pool 4 total pool size calculation
112 #define POOL_ID4_POOL_SZ (POOL_ID4_SZ + POOL_ID4_OVERHEAD)
113
114 /******************************** Pool ID 5 ********************************/
115 // Pool 5 buffer pool sizes and buffer counts
116 #define POOL_ID5_BLOCK_POOL_CNT 1
117
118 // Buffer 0
119
120 #define POOL_ID5_BUF0_CNT 4
121
122 /* Buffer descriptor size already part of TX size so don't add again */
123 #define POOL_ID5_BUF0_SZ 512
124
125 // Pool 5 total buffer size calculation
126 #define POOL_ID5_SZ (POOL_ID5_BUF0_SZ * POOL_ID5_BUF0_CNT)
127
128 // Pool 5 block pool pointer overhead calculation
129 #define POOL_ID5_OVERHEAD ((POOL_ID5_BUF0_CNT)*POOL_OVERHEAD)
130
131 // Pool 5 total pool size calculation
132 #define POOL_ID5_POOL_SZ (POOL_ID5_SZ + POOL_ID5_OVERHEAD)
133
134 /******************************** Pool ID 6 ********************************/
135 // Pool 6 buffer pool sizes and buffer counts
136 #define POOL_ID6_BLOCK_POOL_CNT 1
137
138 // Buffer 0
139
140 #define POOL_ID6_BUF0_CNT 4
141
142 /* Buffer descriptor size already part of TX size so don't add again */
143 #define POOL_ID6_BUF0_SZ 768
144
145 // Pool 6 total buffer size calculation
146 #define POOL_ID6_SZ (POOL_ID6_BUF0_SZ * POOL_ID6_BUF0_CNT)
147
148 // Pool 6 block pool pointer overhead calculation
149 #define POOL_ID6_OVERHEAD ((POOL_ID6_BUF0_CNT)*POOL_OVERHEAD)
150
151 // Pool 6 total pool size calculation
152 #define POOL_ID6_POOL_SZ (POOL_ID6_SZ + POOL_ID6_OVERHEAD)
153
154 /******************************** Pool ID 7 ********************************/
155 // Pool 7 buffer pool sizes and buffer counts
156 #define POOL_ID7_BLOCK_POOL_CNT 1
157
158 // Buffer 0
159
160 #define POOL_ID7_BUF0_CNT 4
161
162 /* Buffer descriptor size already part of TX size so don't add again */
163 #define POOL_ID7_BUF0_SZ 1024
164
165 // Pool 7 total buffer size calculation
166 #define POOL_ID7_SZ (POOL_ID7_BUF0_SZ * POOL_ID7_BUF0_CNT)
167
168 // Pool 7 block pool pointer overhead calculation
169 #define POOL_ID7_OVERHEAD ((POOL_ID7_BUF0_CNT)*POOL_OVERHEAD)
170
171 // Pool 7 total pool size calculation
172 #define POOL_ID7_POOL_SZ (POOL_ID7_SZ + POOL_ID7_OVERHEAD)
173
174 /******************************** Pool ID 8 ********************************/
175 // Pool 8 buffer pool sizes and buffer counts
176 #define POOL_ID8_BLOCK_POOL_CNT 1
177
178 // Buffer 0
179
180 #define POOL_ID8_BUF0_CNT 4
181
182 /* Buffer descriptor size already part of TX size so don't add again */
183 #define POOL_ID8_BUF0_SZ 1280
184
185 // Pool 8 total buffer size calculation
186 #define POOL_ID8_SZ (POOL_ID8_BUF0_SZ * POOL_ID8_BUF0_CNT)
187
188 // Pool 8 block pool pointer overhead calculation
189 #define POOL_ID8_OVERHEAD ((POOL_ID8_BUF0_CNT)*POOL_OVERHEAD)
190
191 // Pool 8 total pool size calculation
192 #define POOL_ID8_POOL_SZ (POOL_ID8_SZ + POOL_ID8_OVERHEAD)
193
194 /******************************** Pool ID 9 ********************************/
195 // Pool 9 buffer pool sizes and buffer counts
196 #define POOL_ID9_BLOCK_POOL_CNT 1
197
198 // Buffer 0
199
200 #define POOL_ID9_BUF0_CNT 4
201
202 /* Buffer descriptor size already part of TX size so don't add again */
203 #define POOL_ID9_BUF0_SZ 1536
204
205 // Pool 9 total buffer size calculation
206 #define POOL_ID9_SZ (POOL_ID9_BUF0_SZ * POOL_ID9_BUF0_CNT)
207
208 // Pool 9 block pool pointer overhead calculation
209 #define POOL_ID9_OVERHEAD ((POOL_ID9_BUF0_CNT)*POOL_OVERHEAD)
210
211 // Pool 9 total pool size calculation
212 #define POOL_ID9_POOL_SZ (POOL_ID9_SZ + POOL_ID9_OVERHEAD)
213
214 /******************************** Pool ID 10 ********************************/
215 // Pool 10 buffer pool sizes and buffer counts
216 #define POOL_ID10_BLOCK_POOL_CNT 1
217
218 // Buffer 0
219
220 #define POOL_ID10_BUF0_CNT 4
221
222 /* Buffer descriptor size already part of TX size so don't add again */
223 #define POOL_ID10_BUF0_SZ 1792
224
225 // Pool 10 total buffer size calculation
226 #define POOL_ID10_SZ (POOL_ID10_BUF0_SZ * POOL_ID10_BUF0_CNT)
227
228 // Pool 10 block pool pointer overhead calculation
229 #define POOL_ID10_OVERHEAD ((POOL_ID10_BUF0_CNT)*POOL_OVERHEAD)
230
231 // Pool 10 total pool size calculation
232 #define POOL_ID10_POOL_SZ (POOL_ID10_SZ + POOL_ID10_OVERHEAD)
233
234 /******************************** Pool ID 11 ********************************/
235 // Pool 11 buffer pool sizes and buffer counts
236 #define POOL_ID11_BLOCK_POOL_CNT 1
237
238 // Buffer 0
239
240 #define POOL_ID11_BUF0_CNT 4
241
242 /* Buffer descriptor size already part of TX size so don't add again */
243 #define POOL_ID11_BUF0_SZ 2048
244
245 // Pool 11 total buffer size calculation
246 #define POOL_ID11_SZ (POOL_ID11_BUF0_SZ * POOL_ID11_BUF0_CNT)
247
248 // Pool 11 block pool pointer overhead calculation
249 #define POOL_ID11_OVERHEAD ((POOL_ID11_BUF0_CNT)*POOL_OVERHEAD)
250
251 // Pool 11 total pool size calculation
252 #define POOL_ID11_POOL_SZ (POOL_ID11_SZ + POOL_ID11_OVERHEAD)
253
254 /******************************** Pool ID 12 ********************************/
255 // Pool 12 buffer pool sizes and buffer counts
256 #define POOL_ID12_BLOCK_POOL_CNT 1
257
258 // Buffer 0
259
260 #define POOL_ID12_BUF0_CNT 4
261
262 /* Buffer descriptor size already part of TX size so don't add again */
263 #define POOL_ID12_BUF0_SZ 2560
264
265 // Pool 12 total buffer size calculation
266 #define POOL_ID12_SZ (POOL_ID12_BUF0_SZ * POOL_ID12_BUF0_CNT)
267
268 // Pool 12 block pool pointer overhead calculation
269 #define POOL_ID12_OVERHEAD ((POOL_ID12_BUF0_CNT)*POOL_OVERHEAD)
270
271 // Pool 12 total pool size calculation
272 #define POOL_ID12_POOL_SZ (POOL_ID12_SZ + POOL_ID12_OVERHEAD)
273
274 /******************************** Pool ID 13 ********************************/
275 // Pool 13 buffer pool sizes and buffer counts
276 #define POOL_ID13_BLOCK_POOL_CNT 1
277
278 // Buffer 0
279
280 #define POOL_ID13_BUF0_CNT 4
281
282 /* Buffer descriptor size already part of TX size so don't add again */
283 #define POOL_ID13_BUF0_SZ 3072
284
285 // Pool 13 total buffer size calculation
286 #define POOL_ID13_SZ (POOL_ID13_BUF0_SZ * POOL_ID13_BUF0_CNT)
287
288 // Pool 13 block pool pointer overhead calculation
289 #define POOL_ID13_OVERHEAD ((POOL_ID13_BUF0_CNT)*POOL_OVERHEAD)
290
291 // Pool 13 total pool size calculation
292 #define POOL_ID13_POOL_SZ (POOL_ID13_SZ + POOL_ID13_OVERHEAD)
293
294 /******************************** Pool ID 14 ********************************/
295 // Pool 14 buffer pool sizes and buffer counts
296 #define POOL_ID14_BLOCK_POOL_CNT 1
297
298 // Buffer 0
299
300 #define POOL_ID14_BUF0_CNT 4
301
302 /* Buffer descriptor size already part of TX size so don't add again */
303 #define POOL_ID14_BUF0_SZ 4096
304
305 // Pool 14 total buffer size calculation
306 #define POOL_ID14_SZ (POOL_ID14_BUF0_SZ * POOL_ID14_BUF0_CNT)
307
308 // Pool 14 block pool pointer overhead calculation
309 #define POOL_ID14_OVERHEAD ((POOL_ID14_BUF0_CNT)*POOL_OVERHEAD)
310
311 // Pool 14 total pool size calculation
312 #define POOL_ID14_POOL_SZ (POOL_ID14_SZ + POOL_ID14_OVERHEAD)
313
314 MemoryPool_t pmAdapterMemoryPool;
315 MemoryPool_t pmPrivateMemoryPool;
316 MemoryPool_t buf_32_MemoryPool;
317 MemoryPool_t buf_128_MemoryPool;
318 MemoryPool_t buf_256_MemoryPool;
319 MemoryPool_t buf_512_MemoryPool;
320 MemoryPool_t buf_768_MemoryPool;
321 MemoryPool_t buf_1024_MemoryPool;
322 MemoryPool_t buf_1280_MemoryPool;
323 MemoryPool_t buf_1536_MemoryPool;
324 MemoryPool_t buf_1792_MemoryPool;
325 MemoryPool_t buf_2048_MemoryPool;
326 MemoryPool_t buf_2560_MemoryPool;
327 MemoryPool_t buf_3072_MemoryPool;
328 MemoryPool_t buf_4096_MemoryPool;
329
330 static MemPool_t pmAdapterMemPool;
331 static MemPool_t pmPrivateMemPool;
332 static MemPool_t buf_32_MemPool;
333 static MemPool_t buf_128_MemPool;
334 static MemPool_t buf_256_MemPool;
335 static MemPool_t buf_512_MemPool;
336 static MemPool_t buf_768_MemPool;
337 static MemPool_t buf_1024_MemPool;
338 static MemPool_t buf_1280_MemPool;
339 static MemPool_t buf_1536_MemPool;
340 static MemPool_t buf_1792_MemPool;
341 static MemPool_t buf_2048_MemPool;
342 static MemPool_t buf_2560_MemPool;
343 static MemPool_t buf_3072_MemPool;
344 static MemPool_t buf_4096_MemPool;
345
346 /***************** Preallocated pmAdapter pool memory ************************/
347 uint8_t ALIGNED_START(32) pmAdapterBufferPool[POOL_ID0_POOL_SZ];
348
349 /***************** Preallocated pmPrivate pool memory ************************/
350 uint8_t ALIGNED_START(32) pmPrivateBufferPool[POOL_ID1_POOL_SZ];
351
352 /***************** Preallocated buffer 32 pool memory ************************/
353 uint8_t ALIGNED_START(32) buf_32_BufferPool[POOL_ID2_POOL_SZ];
354
355 uint8_t ALIGNED_START(32) buf_128_BufferPool[POOL_ID3_POOL_SZ];
356 uint8_t ALIGNED_START(32) buf_256_BufferPool[POOL_ID4_POOL_SZ];
357 uint8_t ALIGNED_START(32) buf_512_BufferPool[POOL_ID5_POOL_SZ];
358 uint8_t ALIGNED_START(32) buf_768_BufferPool[POOL_ID6_POOL_SZ];
359 uint8_t ALIGNED_START(32) buf_1024_BufferPool[POOL_ID7_POOL_SZ];
360 uint8_t ALIGNED_START(32) buf_1280_BufferPool[POOL_ID8_POOL_SZ];
361 uint8_t ALIGNED_START(32) buf_1536_BufferPool[POOL_ID9_POOL_SZ];
362 uint8_t ALIGNED_START(32) buf_1792_BufferPool[POOL_ID10_POOL_SZ];
363 uint8_t ALIGNED_START(32) buf_2048_BufferPool[POOL_ID11_POOL_SZ];
364 uint8_t ALIGNED_START(32) buf_2560_BufferPool[POOL_ID12_POOL_SZ];
365 uint8_t ALIGNED_START(32) buf_3072_BufferPool[POOL_ID13_POOL_SZ];
366 uint8_t ALIGNED_START(32) buf_4096_BufferPool[POOL_ID14_POOL_SZ];
367
mem_pool_init()368 int mem_pool_init()
369 {
370 int ret = -1;
371
372 pmAdapterMemoryPool =
373 OSA_MemoryPoolCreate(&pmAdapterMemPool, POOL_ID0_BUF0_SZ, (void *)pmAdapterBufferPool, POOL_ID0_POOL_SZ, 0);
374 if (pmAdapterMemoryPool == NULL)
375 {
376 mpool_e("Failed to init pmAdapter Buffer Pool");
377 return ret;
378 }
379
380 pmPrivateMemoryPool =
381 OSA_MemoryPoolCreate(&pmPrivateMemPool, POOL_ID1_BUF0_SZ, (void *)pmPrivateBufferPool, POOL_ID1_POOL_SZ, 0);
382 if (pmPrivateMemoryPool == NULL)
383 {
384 mpool_e("Failed to init pmAdapter Buffer Pool");
385 return ret;
386 }
387
388 buf_32_MemoryPool =
389 OSA_MemoryPoolCreate(&buf_32_MemPool, POOL_ID2_BUF0_SZ, (void *)buf_32_BufferPool, POOL_ID2_POOL_SZ, 0);
390 if (buf_32_MemoryPool == NULL)
391 {
392 mpool_e("Failed to init buf 32 Buffer Pool");
393 return ret;
394 }
395
396 buf_128_MemoryPool =
397 OSA_MemoryPoolCreate(&buf_128_MemPool, POOL_ID3_BUF0_SZ, (void *)buf_128_BufferPool, POOL_ID3_POOL_SZ, 0);
398 if (buf_128_MemoryPool == NULL)
399 {
400 mpool_e("Failed to init buf 128 Buffer Pool");
401 return ret;
402 }
403
404 buf_256_MemoryPool =
405 OSA_MemoryPoolCreate(&buf_256_MemPool, POOL_ID4_BUF0_SZ, (void *)buf_256_BufferPool, POOL_ID4_POOL_SZ, 0);
406 if (buf_256_MemoryPool == NULL)
407 {
408 mpool_e("Failed to init buf 256 Buffer Pool");
409 return ret;
410 }
411
412 buf_512_MemoryPool =
413 OSA_MemoryPoolCreate(&buf_512_MemPool, POOL_ID5_BUF0_SZ, (void *)buf_512_BufferPool, POOL_ID5_POOL_SZ, 0);
414 if (buf_512_MemoryPool == NULL)
415 {
416 mpool_e("Failed to init buf 512 Buffer Pool");
417 return ret;
418 }
419
420 buf_768_MemoryPool =
421 OSA_MemoryPoolCreate(&buf_768_MemPool, POOL_ID6_BUF0_SZ, (void *)buf_768_BufferPool, POOL_ID6_POOL_SZ, 0);
422 if (buf_768_MemoryPool == NULL)
423 {
424 mpool_e("Failed to init buf 768 Buffer Pool");
425 return ret;
426 }
427
428 buf_1024_MemoryPool =
429 OSA_MemoryPoolCreate(&buf_1024_MemPool, POOL_ID7_BUF0_SZ, (void *)buf_1024_BufferPool, POOL_ID7_POOL_SZ, 0);
430 if (buf_1024_MemoryPool == NULL)
431 {
432 mpool_e("Failed to init buf 1024 Buffer Pool");
433 return ret;
434 }
435
436 buf_1280_MemoryPool =
437 OSA_MemoryPoolCreate(&buf_1280_MemPool, POOL_ID8_BUF0_SZ, (void *)buf_1280_BufferPool, POOL_ID8_POOL_SZ, 0);
438 if (buf_1280_MemoryPool == NULL)
439 {
440 mpool_e("Failed to init buf 1280 Buffer Pool");
441 return ret;
442 }
443
444 buf_1536_MemoryPool =
445 OSA_MemoryPoolCreate(&buf_1536_MemPool, POOL_ID9_BUF0_SZ, (void *)buf_1536_BufferPool, POOL_ID9_POOL_SZ, 0);
446 if (buf_1536_MemoryPool == NULL)
447 {
448 mpool_e("Failed to init buf 1536 Buffer Pool");
449 return ret;
450 }
451
452 buf_1792_MemoryPool =
453 OSA_MemoryPoolCreate(&buf_1792_MemPool, POOL_ID10_BUF0_SZ, (void *)buf_1792_BufferPool, POOL_ID10_POOL_SZ, 0);
454 if (buf_1792_MemoryPool == NULL)
455 {
456 mpool_e("Failed to init buf 1792 Buffer Pool");
457 return ret;
458 }
459
460 buf_2048_MemoryPool =
461 OSA_MemoryPoolCreate(&buf_2048_MemPool, POOL_ID11_BUF0_SZ, (void *)buf_2048_BufferPool, POOL_ID11_POOL_SZ, 0);
462 if (buf_2048_MemoryPool == NULL)
463 {
464 mpool_e("Failed to init buf 2048 Buffer Pool");
465 return ret;
466 }
467
468 buf_2560_MemoryPool =
469 OSA_MemoryPoolCreate(&buf_2560_MemPool, POOL_ID12_BUF0_SZ, (void *)buf_2560_BufferPool, POOL_ID12_POOL_SZ, 0);
470 if (buf_2560_MemoryPool == NULL)
471 {
472 mpool_e("Failed to init buf 2560 Buffer Pool");
473 return ret;
474 }
475
476 buf_3072_MemoryPool =
477 OSA_MemoryPoolCreate(&buf_3072_MemPool, POOL_ID13_BUF0_SZ, (void *)buf_3072_BufferPool, POOL_ID13_POOL_SZ, 0);
478 if (buf_3072_MemoryPool == NULL)
479 {
480 mpool_e("Failed to init buf 3072 Buffer Pool");
481 return ret;
482 }
483
484 buf_4096_MemoryPool =
485 OSA_MemoryPoolCreate(&buf_4096_MemPool, POOL_ID14_BUF0_SZ, (void *)buf_4096_BufferPool, POOL_ID14_POOL_SZ, 0);
486 if (buf_4096_MemoryPool == NULL)
487 {
488 mpool_e("Failed to init buf 4096 Buffer Pool");
489 return ret;
490 }
491
492 return 0;
493 }
494
495 #endif
496