remove version in all files
[dpdk.git] / app / test / test_memzone.c
1 /*-
2  *   BSD LICENSE
3  * 
4  *   Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  * 
7  *   Redistribution and use in source and binary forms, with or without 
8  *   modification, are permitted provided that the following conditions 
9  *   are met:
10  * 
11  *     * Redistributions of source code must retain the above copyright 
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright 
14  *       notice, this list of conditions and the following disclaimer in 
15  *       the documentation and/or other materials provided with the 
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its 
18  *       contributors may be used to endorse or promote products derived 
19  *       from this software without specific prior written permission.
20  * 
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  * 
33  */
34
35 #include <stdio.h>
36 #include <stdint.h>
37 #include <inttypes.h>
38 #include <sys/queue.h>
39
40 #include <cmdline_parse.h>
41
42 #include <rte_memory.h>
43 #include <rte_memzone.h>
44 #include <rte_tailq.h>
45 #include <rte_eal.h>
46 #include <rte_common.h>
47
48 #include "test.h"
49
50 /*
51  * Memzone
52  * =======
53  *
54  * - Search for three reserved zones or reserve them if they do not exist:
55  *
56  *   - One is on any socket id.
57  *   - The second is on socket 0.
58  *   - The last one is on socket 1 (if socket 1 exists).
59  *
60  * - Check that the zones exist.
61  *
62  * - Check that the zones are cache-aligned.
63  *
64  * - Check that zones do not overlap.
65  *
66  * - Check that the zones are on the correct socket id.
67  *
68  * - Check that a lookup of the first zone returns the same pointer.
69  *
70  * - Check that it is not possible to create another zone with the
71  *   same name as an existing zone.
72  *
73  * - Check flags for specific huge page size reservation
74  */
75
76 /* Test if memory overlaps: return 1 if true, or 0 if false. */
77 static int
78 is_memory_overlap(phys_addr_t ptr1, size_t len1, phys_addr_t ptr2, size_t len2)
79 {
80         if (ptr2 >= ptr1 && (ptr2 - ptr1) < len1)
81                 return 1;
82         else if (ptr2 < ptr1 && (ptr1 - ptr2) < len2)
83                 return 1;
84         return 0;
85 }
86
87 static int
88 test_memzone_invalid_alignment(void)
89 {
90         const struct rte_memzone * mz;
91
92         mz = rte_memzone_lookup("invalid_alignment");
93         if (mz != NULL) {
94                 printf("Zone with invalid alignment has been reserved\n");
95                 return -1;
96         }
97
98         mz = rte_memzone_reserve_aligned("invalid_alignment", 100,
99                         SOCKET_ID_ANY, 0, 100);
100         if (mz != NULL) {
101                 printf("Zone with invalid alignment has been reserved\n");
102                 return -1;
103         }
104         return 0;
105 }
106
107 static int
108 test_memzone_reserving_zone_size_bigger_than_the_maximum(void)
109 {
110         const struct rte_memzone * mz;
111
112         mz = rte_memzone_lookup("zone_size_bigger_than_the_maximum");
113         if (mz != NULL) {
114                 printf("zone_size_bigger_than_the_maximum has been reserved\n");
115                 return -1;
116         }
117
118         mz = rte_memzone_reserve("zone_size_bigger_than_the_maximum", 0x1900000000ULL,
119                         SOCKET_ID_ANY, 0);
120         if (mz != NULL) {
121                 printf("It is impossible to reserve such big a memzone\n");
122                 return -1;
123         }
124
125         return 0;
126 }
127
128 static int
129 test_memzone_reserve_flags(void)
130 {
131         const struct rte_memzone *mz;
132         const struct rte_memseg *ms;
133         int hugepage_2MB_avail = 0;
134         int hugepage_1GB_avail = 0;
135         const int size = 100;
136         int i = 0;
137         ms = rte_eal_get_physmem_layout();
138         for (i = 0; i < RTE_MAX_MEMSEG; i++) {
139                 if (ms[i].hugepage_sz == RTE_PGSIZE_2M)
140                         hugepage_2MB_avail = 1;
141                 if (ms[i].hugepage_sz == RTE_PGSIZE_1G)
142                         hugepage_1GB_avail = 1;
143         }
144         /* Display the availability of 2MB and 1GB pages */
145         if (hugepage_2MB_avail)
146                 printf("2MB Huge pages available\n");
147         if (hugepage_1GB_avail)
148                 printf("1GB Huge pages available\n");
149         /*
150          * If 2MB pages available, check that a small memzone is correctly
151          * reserved from 2MB huge pages when requested by the RTE_MEMZONE_2MB flag.
152          * Also check that RTE_MEMZONE_SIZE_HINT_ONLY flag only defaults to an
153          * available page size (i.e 1GB ) when 2MB pages are unavailable.
154          */
155         if (hugepage_2MB_avail) {
156                 mz = rte_memzone_reserve("flag_zone_2M", size, SOCKET_ID_ANY,
157                                 RTE_MEMZONE_2MB);
158                 if (mz == NULL) {
159                         printf("MEMZONE FLAG 2MB\n");
160                         return -1;
161                 }
162                 if (mz->hugepage_sz != RTE_PGSIZE_2M) {
163                         printf("hugepage_sz not equal 2M\n");
164                         return -1;
165                 }
166
167                 mz = rte_memzone_reserve("flag_zone_2M_HINT", size, SOCKET_ID_ANY,
168                                 RTE_MEMZONE_2MB|RTE_MEMZONE_SIZE_HINT_ONLY);
169                 if (mz == NULL) {
170                         printf("MEMZONE FLAG 2MB\n");
171                         return -1;
172                 }
173                 if (mz->hugepage_sz != RTE_PGSIZE_2M) {
174                         printf("hugepage_sz not equal 2M\n");
175                         return -1;
176                 }
177
178                 /* Check if 1GB huge pages are unavailable, that function fails unless
179                  * HINT flag is indicated
180                  */
181                 if (!hugepage_1GB_avail) {
182                         mz = rte_memzone_reserve("flag_zone_1G_HINT", size, SOCKET_ID_ANY,
183                                         RTE_MEMZONE_1GB|RTE_MEMZONE_SIZE_HINT_ONLY);
184                         if (mz == NULL) {
185                                 printf("MEMZONE FLAG 1GB & HINT\n");
186                                 return -1;
187                         }
188                         if (mz->hugepage_sz != RTE_PGSIZE_2M) {
189                                 printf("hugepage_sz not equal 2M\n");
190                                 return -1;
191                         }
192
193                         mz = rte_memzone_reserve("flag_zone_1G", size, SOCKET_ID_ANY,
194                                         RTE_MEMZONE_1GB);
195                         if (mz != NULL) {
196                                 printf("MEMZONE FLAG 1GB\n");
197                                 return -1;
198                         }
199                 }
200         }
201
202         /*As with 2MB tests above for 1GB huge page requests*/
203         if (hugepage_1GB_avail) {
204                 mz = rte_memzone_reserve("flag_zone_1G", size, SOCKET_ID_ANY,
205                                 RTE_MEMZONE_1GB);
206                 if (mz == NULL) {
207                         printf("MEMZONE FLAG 1GB\n");
208                         return -1;
209                 }
210                 if (mz->hugepage_sz != RTE_PGSIZE_1G) {
211                         printf("hugepage_sz not equal 1G\n");
212                         return -1;
213                 }
214
215                 mz = rte_memzone_reserve("flag_zone_1G_HINT", size, SOCKET_ID_ANY,
216                                 RTE_MEMZONE_1GB|RTE_MEMZONE_SIZE_HINT_ONLY);
217                 if (mz == NULL) {
218                         printf("MEMZONE FLAG 1GB\n");
219                         return -1;
220                 }
221                 if (mz->hugepage_sz != RTE_PGSIZE_1G) {
222                         printf("hugepage_sz not equal 1G\n");
223                         return -1;
224                 }
225
226                 /* Check if 1GB huge pages are unavailable, that function fails unless
227                  * HINT flag is indicated
228                  */
229                 if (!hugepage_2MB_avail) {
230                         mz = rte_memzone_reserve("flag_zone_2M_HINT", size, SOCKET_ID_ANY,
231                                         RTE_MEMZONE_2MB|RTE_MEMZONE_SIZE_HINT_ONLY);
232                         if (mz == NULL){
233                                 printf("MEMZONE FLAG 2MB & HINT\n");
234                                 return -1;
235                         }
236                         if (mz->hugepage_sz != RTE_PGSIZE_1G) {
237                                 printf("hugepage_sz not equal 1G\n");
238                                 return -1;
239                         }
240                         mz = rte_memzone_reserve("flag_zone_2M", size, SOCKET_ID_ANY,
241                                         RTE_MEMZONE_2MB);
242                         if (mz != NULL) {
243                                 printf("MEMZONE FLAG 2MB\n");
244                                 return -1;
245                         }
246                 }
247
248                 if (hugepage_2MB_avail && hugepage_1GB_avail) {
249                         mz = rte_memzone_reserve("flag_zone_2M_HINT", size, SOCKET_ID_ANY,
250                                                                 RTE_MEMZONE_2MB|RTE_MEMZONE_1GB);
251                         if (mz != NULL) {
252                                 printf("BOTH SIZES SET\n");
253                                 return -1;
254                         }
255                 }
256         }
257         return 0;
258 }
259
260 static int
261 test_memzone_reserve_max(void)
262 {
263         const struct rte_memzone *mz;
264         const struct rte_config *config;
265         const struct rte_memseg *ms;
266         int memseg_idx = 0;
267         int memzone_idx = 0;
268         uint64_t len = 0;
269         void* last_addr;
270         uint64_t maxlen = 0;
271
272         /* get pointer to global configuration */
273         config = rte_eal_get_configuration();
274
275         ms = rte_eal_get_physmem_layout();
276
277         for (memseg_idx = 0; memseg_idx < RTE_MAX_MEMSEG; memseg_idx++){
278                 /* ignore smaller memsegs as they can only get smaller */
279                 if (ms[memseg_idx].len < maxlen)
280                         continue;
281
282                 len = ms[memseg_idx].len;
283                 last_addr = ms[memseg_idx].addr;
284
285                 /* cycle through all memzones */
286                 for (memzone_idx = 0; memzone_idx < RTE_MAX_MEMZONE; memzone_idx++) {
287
288                         /* stop when reaching last allocated memzone */
289                         if (config->mem_config->memzone[memzone_idx].addr == NULL)
290                                 break;
291
292                         /* check if the memzone is in our memseg and subtract length */
293                         if ((config->mem_config->memzone[memzone_idx].addr >=
294                                         ms[memseg_idx].addr) &&
295                                         (config->mem_config->memzone[memzone_idx].addr <=
296                                         (RTE_PTR_ADD(ms[memseg_idx].addr,
297                                         (size_t)ms[memseg_idx].len)))) {
298                                 /* since the zones can now be aligned and occasionally skip
299                                  * some space, we should calculate the length based on
300                                  * reported length and start addresses difference. Addresses
301                                  * are allocated sequentially so we don't need to worry about
302                                  * them being in the right order.
303                                  */
304                                 len -= (uintptr_t) RTE_PTR_SUB(
305                                                 config->mem_config->memzone[memzone_idx].addr,
306                                                 (uintptr_t) last_addr);
307                                 len -= config->mem_config->memzone[memzone_idx].len;
308                                 last_addr =
309                                                 RTE_PTR_ADD(config->mem_config->memzone[memzone_idx].addr,
310                                                 (size_t) config->mem_config->memzone[memzone_idx].len);
311                         }
312                 }
313
314                 /* we don't need to calculate offset here since length
315                  * is always cache-aligned */
316                 if (len > maxlen)
317                         maxlen = len;
318         }
319
320         mz = rte_memzone_reserve("max_zone", 0, SOCKET_ID_ANY, 0);
321         if (mz == NULL){
322                 printf("Failed to reserve a big chunk of memory\n");
323                 rte_dump_physmem_layout();
324                 rte_memzone_dump();
325                 return -1;
326         }
327
328         if (mz->len != maxlen) {
329                 printf("Memzone reserve with 0 size did not return bigest block\n");
330                 printf("Expected size = %" PRIu64 ", actual size = %" PRIu64 "\n",
331                                 maxlen, mz->len);
332                 rte_dump_physmem_layout();
333                 rte_memzone_dump();
334
335                 return -1;
336         }
337         return 0;
338 }
339
340 static int
341 test_memzone_reserve_max_aligned(void)
342 {
343         const struct rte_memzone *mz;
344         const struct rte_config *config;
345         const struct rte_memseg *ms;
346         int memseg_idx = 0;
347         int memzone_idx = 0;
348         uint64_t addr_offset, len = 0;
349         void* last_addr;
350         uint64_t maxlen = 0;
351
352         /* get pointer to global configuration */
353         config = rte_eal_get_configuration();
354
355         ms = rte_eal_get_physmem_layout();
356
357         addr_offset = 0;
358
359         for (memseg_idx = 0; memseg_idx < RTE_MAX_MEMSEG; memseg_idx++){
360
361                 /* ignore smaller memsegs as they can only get smaller */
362                 if (ms[memseg_idx].len < maxlen)
363                         continue;
364
365                 len = ms[memseg_idx].len;
366                 last_addr = ms[memseg_idx].addr;
367
368                 /* cycle through all memzones */
369                 for (memzone_idx = 0; memzone_idx < RTE_MAX_MEMZONE; memzone_idx++) {
370
371                         /* stop when reaching last allocated memzone */
372                         if (config->mem_config->memzone[memzone_idx].addr == NULL)
373                                 break;
374
375                         /* check if the memzone is in our memseg and subtract length */
376                         if ((config->mem_config->memzone[memzone_idx].addr >=
377                                         ms[memseg_idx].addr) &&
378                                         (config->mem_config->memzone[memzone_idx].addr <=
379                                         (RTE_PTR_ADD(ms[memseg_idx].addr,
380                                         (size_t) ms[memseg_idx].len)))) {
381                                 /* since the zones can now be aligned and occasionally skip
382                                  * some space, we should calculate the length based on
383                                  * reported length and start addresses difference.
384                                  */
385                                 len -= (uintptr_t) RTE_PTR_SUB(
386                                                 config->mem_config->memzone[memzone_idx].addr,
387                                                 (uintptr_t) last_addr);
388                                 len -= config->mem_config->memzone[memzone_idx].len;
389                                 last_addr =
390                                                 RTE_PTR_ADD(config->mem_config->memzone[memzone_idx].addr,
391                                                 (size_t) config->mem_config->memzone[memzone_idx].len);
392                         }
393                 }
394
395                 /* make sure we get the alignment offset */
396                 if (len > maxlen) {
397                         addr_offset = RTE_ALIGN_CEIL((uintptr_t) last_addr, 512) - (uintptr_t) last_addr;
398                         maxlen = len;
399                 }
400         }
401
402         maxlen -= addr_offset;
403
404         mz = rte_memzone_reserve_aligned("max_zone_aligned", 0,
405                         SOCKET_ID_ANY, 0, 512);
406         if (mz == NULL){
407                 printf("Failed to reserve a big chunk of memory\n");
408                 rte_dump_physmem_layout();
409                 rte_memzone_dump();
410                 return -1;
411         }
412
413         if (mz->len != maxlen) {
414                 printf("Memzone reserve with 0 size and alignment 512 did not return"
415                                 " bigest block\n");
416                 printf("Expected size = %" PRIu64 ", actual size = %" PRIu64 "\n",
417                                 maxlen, mz->len);
418                 rte_dump_physmem_layout();
419                 rte_memzone_dump();
420
421                 return -1;
422         }
423         return 0;
424 }
425
426 static int
427 test_memzone_aligned(void)
428 {
429         const struct rte_memzone *memzone_aligned_32;
430         const struct rte_memzone *memzone_aligned_128;
431         const struct rte_memzone *memzone_aligned_256;
432         const struct rte_memzone *memzone_aligned_512;
433         const struct rte_memzone *memzone_aligned_1024;
434
435         /* memzone that should automatically be adjusted to align on 64 bytes */
436         memzone_aligned_32 = rte_memzone_lookup("aligned_32");
437         if (memzone_aligned_32 == NULL)
438                 memzone_aligned_32 = rte_memzone_reserve_aligned("aligned_32", 100,
439                                 SOCKET_ID_ANY, 0, 32);
440
441         /* memzone that is supposed to be aligned on a 128 byte boundary */
442         memzone_aligned_128 = rte_memzone_lookup("aligned_128");
443         if (memzone_aligned_128 == NULL)
444                 memzone_aligned_128 = rte_memzone_reserve_aligned("aligned_128", 100,
445                                 SOCKET_ID_ANY, 0, 128);
446
447         /* memzone that is supposed to be aligned on a 256 byte boundary */
448         memzone_aligned_256 = rte_memzone_lookup("aligned_256");
449         if (memzone_aligned_256 == NULL)
450                 memzone_aligned_256 = rte_memzone_reserve_aligned("aligned_256", 100,
451                                 SOCKET_ID_ANY, 0, 256);
452
453         /* memzone that is supposed to be aligned on a 512 byte boundary */
454         memzone_aligned_512 = rte_memzone_lookup("aligned_512");
455         if (memzone_aligned_512 == NULL)
456                 memzone_aligned_512 = rte_memzone_reserve_aligned("aligned_512", 100,
457                                 SOCKET_ID_ANY, 0, 512);
458
459         /* memzone that is supposed to be aligned on a 1024 byte boundary */
460         memzone_aligned_1024 = rte_memzone_lookup("aligned_1024");
461         if (memzone_aligned_1024 == NULL)
462                 memzone_aligned_1024 = rte_memzone_reserve_aligned("aligned_1024", 100,
463                                 SOCKET_ID_ANY, 0, 1024);
464
465         printf("check alignments and lengths\n");
466         if ((memzone_aligned_32->phys_addr & CACHE_LINE_MASK) != 0)
467                 return -1;
468         if (((uintptr_t) memzone_aligned_32->addr & CACHE_LINE_MASK) != 0)
469                 return -1;
470         if ((memzone_aligned_32->len & CACHE_LINE_MASK) != 0)
471                 return -1;
472         if ((memzone_aligned_128->phys_addr & 127) != 0)
473                 return -1;
474         if (((uintptr_t) memzone_aligned_128->addr & 127) != 0)
475                 return -1;
476         if ((memzone_aligned_128->len & CACHE_LINE_MASK) != 0)
477                 return -1;
478         if ((memzone_aligned_256->phys_addr & 255) != 0)
479                 return -1;
480         if (((uintptr_t) memzone_aligned_256->addr & 255) != 0)
481                 return -1;
482         if ((memzone_aligned_256->len & CACHE_LINE_MASK) != 0)
483                 return -1;
484         if ((memzone_aligned_512->phys_addr & 511) != 0)
485                 return -1;
486         if (((uintptr_t) memzone_aligned_512->addr & 511) != 0)
487                 return -1;
488         if ((memzone_aligned_512->len & CACHE_LINE_MASK) != 0)
489                 return -1;
490         if ((memzone_aligned_1024->phys_addr & 1023) != 0)
491                 return -1;
492         if (((uintptr_t) memzone_aligned_1024->addr & 1023) != 0)
493                 return -1;
494         if ((memzone_aligned_1024->len & CACHE_LINE_MASK) != 0)
495                 return -1;
496
497
498         /* check that zones don't overlap */
499         printf("check overlapping\n");
500         if (is_memory_overlap(memzone_aligned_32->phys_addr, memzone_aligned_32->len,
501                                         memzone_aligned_128->phys_addr, memzone_aligned_128->len))
502                 return -1;
503         if (is_memory_overlap(memzone_aligned_32->phys_addr, memzone_aligned_32->len,
504                                         memzone_aligned_256->phys_addr, memzone_aligned_256->len))
505                 return -1;
506         if (is_memory_overlap(memzone_aligned_32->phys_addr, memzone_aligned_32->len,
507                                         memzone_aligned_512->phys_addr, memzone_aligned_512->len))
508                 return -1;
509         if (is_memory_overlap(memzone_aligned_32->phys_addr, memzone_aligned_32->len,
510                                         memzone_aligned_1024->phys_addr, memzone_aligned_1024->len))
511                 return -1;
512         if (is_memory_overlap(memzone_aligned_128->phys_addr, memzone_aligned_128->len,
513                                         memzone_aligned_256->phys_addr, memzone_aligned_256->len))
514                 return -1;
515         if (is_memory_overlap(memzone_aligned_128->phys_addr, memzone_aligned_128->len,
516                                         memzone_aligned_512->phys_addr, memzone_aligned_512->len))
517                 return -1;
518         if (is_memory_overlap(memzone_aligned_128->phys_addr, memzone_aligned_128->len,
519                                         memzone_aligned_1024->phys_addr, memzone_aligned_1024->len))
520                 return -1;
521         if (is_memory_overlap(memzone_aligned_256->phys_addr, memzone_aligned_256->len,
522                                         memzone_aligned_512->phys_addr, memzone_aligned_512->len))
523                 return -1;
524         if (is_memory_overlap(memzone_aligned_256->phys_addr, memzone_aligned_256->len,
525                                         memzone_aligned_1024->phys_addr, memzone_aligned_1024->len))
526                 return -1;
527         if (is_memory_overlap(memzone_aligned_512->phys_addr, memzone_aligned_512->len,
528                                         memzone_aligned_1024->phys_addr, memzone_aligned_1024->len))
529                 return -1;
530         return 0;
531 }
532
533 int
534 test_memzone(void)
535 {
536         const struct rte_memzone *memzone1;
537         const struct rte_memzone *memzone2;
538         const struct rte_memzone *memzone3;
539         const struct rte_memzone *mz;
540
541         memzone1 = rte_memzone_lookup("testzone1");
542         if (memzone1 == NULL)
543                 memzone1 = rte_memzone_reserve("testzone1", 100,
544                                 SOCKET_ID_ANY, 0);
545
546         memzone2 = rte_memzone_lookup("testzone2");
547         if (memzone2 == NULL)
548                 memzone2 = rte_memzone_reserve("testzone2", 1000,
549                                 0, 0);
550
551         memzone3 = rte_memzone_lookup("testzone3");
552         if (memzone3 == NULL)
553                 memzone3 = rte_memzone_reserve("testzone3", 1000,
554                                 1, 0);
555
556         /* memzone3 may be NULL if we don't have NUMA */
557         if (memzone1 == NULL || memzone2 == NULL)
558                 return -1;
559
560         rte_memzone_dump();
561
562         /* check cache-line alignments */
563         printf("check alignments and lengths\n");
564
565         if ((memzone1->phys_addr & CACHE_LINE_MASK) != 0)
566                 return -1;
567         if ((memzone2->phys_addr & CACHE_LINE_MASK) != 0)
568                 return -1;
569         if (memzone3 != NULL && (memzone3->phys_addr & CACHE_LINE_MASK) != 0)
570                 return -1;
571         if ((memzone1->len & CACHE_LINE_MASK) != 0 || memzone1->len == 0)
572                 return -1;
573         if ((memzone2->len & CACHE_LINE_MASK) != 0 || memzone2->len == 0)
574                 return -1;
575         if (memzone3 != NULL && ((memzone3->len & CACHE_LINE_MASK) != 0 ||
576                         memzone3->len == 0))
577                 return -1;
578
579         /* check that zones don't overlap */
580         printf("check overlapping\n");
581
582         if (is_memory_overlap(memzone1->phys_addr, memzone1->len,
583                         memzone2->phys_addr, memzone2->len))
584                 return -1;
585         if (memzone3 != NULL &&
586                         is_memory_overlap(memzone1->phys_addr, memzone1->len,
587                                         memzone3->phys_addr, memzone3->len))
588                 return -1;
589         if (memzone3 != NULL &&
590                         is_memory_overlap(memzone2->phys_addr, memzone2->len,
591                                         memzone3->phys_addr, memzone3->len))
592                 return -1;
593
594         printf("check socket ID\n");
595
596         /* memzone2 must be on socket id 0 and memzone3 on socket 1 */
597         if (memzone2->socket_id != 0)
598                 return -1;
599         if (memzone3 != NULL && memzone3->socket_id != 1)
600                 return -1;
601
602         printf("test zone lookup\n");
603         mz = rte_memzone_lookup("testzone1");
604         if (mz != memzone1)
605                 return -1;
606
607         printf("test duplcate zone name\n");
608         mz = rte_memzone_reserve("testzone1", 100,
609                         SOCKET_ID_ANY, 0);
610         if (mz != NULL)
611                 return -1;
612
613         printf("test reserving memzone with bigger size than the maximum\n");
614         if (test_memzone_reserving_zone_size_bigger_than_the_maximum() < 0)
615                 return -1;
616
617         printf("test reserving the largest size memzone possible\n");
618         if (test_memzone_reserve_max() < 0)
619                 return -1;
620
621         printf("test memzone_reserve flags\n");
622         if (test_memzone_reserve_flags() < 0)
623                 return -1;
624
625         printf("test alignment for memzone_reserve\n");
626         if (test_memzone_aligned() < 0)
627                 return -1;
628
629         printf("test invalid alignment for memzone_reserve\n");
630         if (test_memzone_invalid_alignment() < 0)
631                 return -1;
632
633         printf("test reserving the largest size aligned memzone possible\n");
634         if (test_memzone_reserve_max_aligned() < 0)
635                 return -1;
636
637         return 0;
638 }