4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
41 #include <sys/queue.h>
43 #include <rte_common.h>
44 #include <rte_debug.h>
46 #include <rte_common.h>
47 #include <rte_memory.h>
48 #include <rte_memcpy.h>
49 #include <rte_memzone.h>
50 #include <rte_launch.h>
52 #include <rte_per_lcore.h>
53 #include <rte_lcore.h>
54 #include <rte_atomic.h>
55 #include <rte_branch_prediction.h>
57 #include <rte_mempool.h>
59 #include <rte_random.h>
60 #include <rte_cycles.h>
64 #define MBUF_DATA_SIZE 2048
66 #define MBUF_TEST_DATA_LEN 1464
67 #define MBUF_TEST_DATA_LEN2 50
68 #define MBUF_TEST_HDR1_LEN 20
69 #define MBUF_TEST_HDR2_LEN 30
70 #define MBUF_TEST_ALL_HDRS_LEN (MBUF_TEST_HDR1_LEN+MBUF_TEST_HDR2_LEN)
72 #define REFCNT_MAX_ITER 64
73 #define REFCNT_MAX_TIMEOUT 10
74 #define REFCNT_MAX_REF (RTE_MAX_LCORE)
75 #define REFCNT_MBUF_NUM 64
76 #define REFCNT_RING_SIZE (REFCNT_MBUF_NUM * REFCNT_MAX_REF)
78 #define MAGIC_DATA 0x42424242
80 #define MAKE_STRING(x) # x
82 static struct rte_mempool *pktmbuf_pool = NULL;
84 #ifdef RTE_MBUF_REFCNT_ATOMIC
86 static struct rte_mempool *refcnt_pool = NULL;
87 static struct rte_ring *refcnt_mbuf_ring = NULL;
88 static volatile uint32_t refcnt_stop_slaves;
89 static unsigned refcnt_lcore[RTE_MAX_LCORE];
97 * #. Allocate a mbuf pool.
99 * - The pool contains NB_MBUF elements, where each mbuf is MBUF_SIZE
102 * #. Test multiple allocations of mbufs from this pool.
104 * - Allocate NB_MBUF and store pointers in a table.
105 * - If an allocation fails, return an error.
106 * - Free all these mbufs.
107 * - Repeat the same test to check that mbufs were freed correctly.
109 * #. Test data manipulation in pktmbuf.
112 * - Append data using rte_pktmbuf_append().
113 * - Test for error in rte_pktmbuf_append() when len is too large.
114 * - Trim data at the end of mbuf using rte_pktmbuf_trim().
115 * - Test for error in rte_pktmbuf_trim() when len is too large.
116 * - Prepend a header using rte_pktmbuf_prepend().
117 * - Test for error in rte_pktmbuf_prepend() when len is too large.
118 * - Remove data at the beginning of mbuf using rte_pktmbuf_adj().
119 * - Test for error in rte_pktmbuf_adj() when len is too large.
120 * - Check that appended data is not corrupt.
122 * - Between all these tests, check data_len and pkt_len, and
123 * that the mbuf is contiguous.
124 * - Repeat the test to check that allocation operations
125 * reinitialize the mbuf correctly.
127 * #. Test packet cloning
128 * - Clone a mbuf and verify the data
131 #define GOTO_FAIL(str, ...) do { \
132 printf("mbuf test FAILED (l.%d): <" str ">\n", \
133 __LINE__, ##__VA_ARGS__); \
138 * test data manipulation in mbuf with non-ascii data
141 test_pktmbuf_with_non_ascii_data(void)
143 struct rte_mbuf *m = NULL;
146 m = rte_pktmbuf_alloc(pktmbuf_pool);
148 GOTO_FAIL("Cannot allocate mbuf");
149 if (rte_pktmbuf_pkt_len(m) != 0)
150 GOTO_FAIL("Bad length");
152 data = rte_pktmbuf_append(m, MBUF_TEST_DATA_LEN);
154 GOTO_FAIL("Cannot append data");
155 if (rte_pktmbuf_pkt_len(m) != MBUF_TEST_DATA_LEN)
156 GOTO_FAIL("Bad pkt length");
157 if (rte_pktmbuf_data_len(m) != MBUF_TEST_DATA_LEN)
158 GOTO_FAIL("Bad data length");
159 memset(data, 0xff, rte_pktmbuf_pkt_len(m));
160 if (!rte_pktmbuf_is_contiguous(m))
161 GOTO_FAIL("Buffer should be continuous");
162 rte_pktmbuf_dump(stdout, m, MBUF_TEST_DATA_LEN);
176 * test data manipulation in mbuf
179 test_one_pktmbuf(void)
181 struct rte_mbuf *m = NULL;
182 char *data, *data2, *hdr;
185 printf("Test pktmbuf API\n");
189 m = rte_pktmbuf_alloc(pktmbuf_pool);
191 GOTO_FAIL("Cannot allocate mbuf");
192 if (rte_pktmbuf_pkt_len(m) != 0)
193 GOTO_FAIL("Bad length");
195 rte_pktmbuf_dump(stdout, m, 0);
199 data = rte_pktmbuf_append(m, MBUF_TEST_DATA_LEN);
201 GOTO_FAIL("Cannot append data");
202 if (rte_pktmbuf_pkt_len(m) != MBUF_TEST_DATA_LEN)
203 GOTO_FAIL("Bad pkt length");
204 if (rte_pktmbuf_data_len(m) != MBUF_TEST_DATA_LEN)
205 GOTO_FAIL("Bad data length");
206 memset(data, 0x66, rte_pktmbuf_pkt_len(m));
207 if (!rte_pktmbuf_is_contiguous(m))
208 GOTO_FAIL("Buffer should be continuous");
209 rte_pktmbuf_dump(stdout, m, MBUF_TEST_DATA_LEN);
210 rte_pktmbuf_dump(stdout, m, 2*MBUF_TEST_DATA_LEN);
212 /* this append should fail */
214 data2 = rte_pktmbuf_append(m, (uint16_t)(rte_pktmbuf_tailroom(m) + 1));
216 GOTO_FAIL("Append should not succeed");
218 /* append some more data */
220 data2 = rte_pktmbuf_append(m, MBUF_TEST_DATA_LEN2);
222 GOTO_FAIL("Cannot append data");
223 if (rte_pktmbuf_pkt_len(m) != MBUF_TEST_DATA_LEN + MBUF_TEST_DATA_LEN2)
224 GOTO_FAIL("Bad pkt length");
225 if (rte_pktmbuf_data_len(m) != MBUF_TEST_DATA_LEN + MBUF_TEST_DATA_LEN2)
226 GOTO_FAIL("Bad data length");
227 if (!rte_pktmbuf_is_contiguous(m))
228 GOTO_FAIL("Buffer should be continuous");
230 /* trim data at the end of mbuf */
232 if (rte_pktmbuf_trim(m, MBUF_TEST_DATA_LEN2) < 0)
233 GOTO_FAIL("Cannot trim data");
234 if (rte_pktmbuf_pkt_len(m) != MBUF_TEST_DATA_LEN)
235 GOTO_FAIL("Bad pkt length");
236 if (rte_pktmbuf_data_len(m) != MBUF_TEST_DATA_LEN)
237 GOTO_FAIL("Bad data length");
238 if (!rte_pktmbuf_is_contiguous(m))
239 GOTO_FAIL("Buffer should be continuous");
241 /* this trim should fail */
243 if (rte_pktmbuf_trim(m, (uint16_t)(rte_pktmbuf_data_len(m) + 1)) == 0)
244 GOTO_FAIL("trim should not succeed");
246 /* prepend one header */
248 hdr = rte_pktmbuf_prepend(m, MBUF_TEST_HDR1_LEN);
250 GOTO_FAIL("Cannot prepend");
251 if (data - hdr != MBUF_TEST_HDR1_LEN)
252 GOTO_FAIL("Prepend failed");
253 if (rte_pktmbuf_pkt_len(m) != MBUF_TEST_DATA_LEN + MBUF_TEST_HDR1_LEN)
254 GOTO_FAIL("Bad pkt length");
255 if (rte_pktmbuf_data_len(m) != MBUF_TEST_DATA_LEN + MBUF_TEST_HDR1_LEN)
256 GOTO_FAIL("Bad data length");
257 if (!rte_pktmbuf_is_contiguous(m))
258 GOTO_FAIL("Buffer should be continuous");
259 memset(hdr, 0x55, MBUF_TEST_HDR1_LEN);
261 /* prepend another header */
263 hdr = rte_pktmbuf_prepend(m, MBUF_TEST_HDR2_LEN);
265 GOTO_FAIL("Cannot prepend");
266 if (data - hdr != MBUF_TEST_ALL_HDRS_LEN)
267 GOTO_FAIL("Prepend failed");
268 if (rte_pktmbuf_pkt_len(m) != MBUF_TEST_DATA_LEN + MBUF_TEST_ALL_HDRS_LEN)
269 GOTO_FAIL("Bad pkt length");
270 if (rte_pktmbuf_data_len(m) != MBUF_TEST_DATA_LEN + MBUF_TEST_ALL_HDRS_LEN)
271 GOTO_FAIL("Bad data length");
272 if (!rte_pktmbuf_is_contiguous(m))
273 GOTO_FAIL("Buffer should be continuous");
274 memset(hdr, 0x55, MBUF_TEST_HDR2_LEN);
276 rte_mbuf_sanity_check(m, 1);
277 rte_mbuf_sanity_check(m, 0);
278 rte_pktmbuf_dump(stdout, m, 0);
280 /* this prepend should fail */
282 hdr = rte_pktmbuf_prepend(m, (uint16_t)(rte_pktmbuf_headroom(m) + 1));
284 GOTO_FAIL("prepend should not succeed");
286 /* remove data at beginning of mbuf (adj) */
288 if (data != rte_pktmbuf_adj(m, MBUF_TEST_ALL_HDRS_LEN))
289 GOTO_FAIL("rte_pktmbuf_adj failed");
290 if (rte_pktmbuf_pkt_len(m) != MBUF_TEST_DATA_LEN)
291 GOTO_FAIL("Bad pkt length");
292 if (rte_pktmbuf_data_len(m) != MBUF_TEST_DATA_LEN)
293 GOTO_FAIL("Bad data length");
294 if (!rte_pktmbuf_is_contiguous(m))
295 GOTO_FAIL("Buffer should be continuous");
297 /* this adj should fail */
299 if (rte_pktmbuf_adj(m, (uint16_t)(rte_pktmbuf_data_len(m) + 1)) != NULL)
300 GOTO_FAIL("rte_pktmbuf_adj should not succeed");
304 if (!rte_pktmbuf_is_contiguous(m))
305 GOTO_FAIL("Buffer should be continuous");
307 for (i=0; i<MBUF_TEST_DATA_LEN; i++) {
309 GOTO_FAIL("Data corrupted at offset %u", i);
325 testclone_testupdate_testdetach(void)
327 struct rte_mbuf *m = NULL;
328 struct rte_mbuf *clone = NULL;
332 m = rte_pktmbuf_alloc(pktmbuf_pool);
334 GOTO_FAIL("ooops not allocating mbuf");
336 if (rte_pktmbuf_pkt_len(m) != 0)
337 GOTO_FAIL("Bad length");
339 rte_pktmbuf_append(m, sizeof(uint32_t));
340 data = rte_pktmbuf_mtod(m, uint32_t *);
343 /* clone the allocated mbuf */
344 clone = rte_pktmbuf_clone(m, pktmbuf_pool);
346 GOTO_FAIL("cannot clone data\n");
348 data = rte_pktmbuf_mtod(clone, uint32_t *);
349 if (*data != MAGIC_DATA)
350 GOTO_FAIL("invalid data in clone\n");
352 if (rte_mbuf_refcnt_read(m) != 2)
353 GOTO_FAIL("invalid refcnt in m\n");
356 rte_pktmbuf_free(clone);
359 /* same test with a chained mbuf */
360 m->next = rte_pktmbuf_alloc(pktmbuf_pool);
362 GOTO_FAIL("Next Pkt Null\n");
364 rte_pktmbuf_append(m->next, sizeof(uint32_t));
365 data = rte_pktmbuf_mtod(m->next, uint32_t *);
368 clone = rte_pktmbuf_clone(m, pktmbuf_pool);
370 GOTO_FAIL("cannot clone data\n");
372 data = rte_pktmbuf_mtod(clone, uint32_t *);
373 if (*data != MAGIC_DATA)
374 GOTO_FAIL("invalid data in clone\n");
376 data = rte_pktmbuf_mtod(clone->next, uint32_t *);
377 if (*data != MAGIC_DATA)
378 GOTO_FAIL("invalid data in clone->next\n");
380 if (rte_mbuf_refcnt_read(m) != 2)
381 GOTO_FAIL("invalid refcnt in m\n");
383 if (rte_mbuf_refcnt_read(m->next) != 2)
384 GOTO_FAIL("invalid refcnt in m->next\n");
388 rte_pktmbuf_free(clone);
397 rte_pktmbuf_free(clone);
405 * test allocation and free of mbufs
408 test_pktmbuf_pool(void)
411 struct rte_mbuf *m[NB_MBUF];
414 for (i=0; i<NB_MBUF; i++)
417 /* alloc NB_MBUF mbufs */
418 for (i=0; i<NB_MBUF; i++) {
419 m[i] = rte_pktmbuf_alloc(pktmbuf_pool);
421 printf("rte_pktmbuf_alloc() failed (%u)\n", i);
425 struct rte_mbuf *extra = NULL;
426 extra = rte_pktmbuf_alloc(pktmbuf_pool);
428 printf("Error pool not empty");
431 extra = rte_pktmbuf_clone(m[0], pktmbuf_pool);
433 printf("Error pool not empty");
437 for (i=0; i<NB_MBUF; i++) {
439 rte_pktmbuf_free(m[i]);
446 * test that the pointer to the data on a packet mbuf is set properly
449 test_pktmbuf_pool_ptr(void)
452 struct rte_mbuf *m[NB_MBUF];
455 for (i=0; i<NB_MBUF; i++)
458 /* alloc NB_MBUF mbufs */
459 for (i=0; i<NB_MBUF; i++) {
460 m[i] = rte_pktmbuf_alloc(pktmbuf_pool);
462 printf("rte_pktmbuf_alloc() failed (%u)\n", i);
465 m[i]->data_off += 64;
469 for (i=0; i<NB_MBUF; i++) {
471 rte_pktmbuf_free(m[i]);
474 for (i=0; i<NB_MBUF; i++)
477 /* alloc NB_MBUF mbufs */
478 for (i=0; i<NB_MBUF; i++) {
479 m[i] = rte_pktmbuf_alloc(pktmbuf_pool);
481 printf("rte_pktmbuf_alloc() failed (%u)\n", i);
484 if (m[i]->data_off != RTE_PKTMBUF_HEADROOM) {
485 printf("invalid data_off\n");
491 for (i=0; i<NB_MBUF; i++) {
493 rte_pktmbuf_free(m[i]);
500 test_pktmbuf_free_segment(void)
503 struct rte_mbuf *m[NB_MBUF];
506 for (i=0; i<NB_MBUF; i++)
509 /* alloc NB_MBUF mbufs */
510 for (i=0; i<NB_MBUF; i++) {
511 m[i] = rte_pktmbuf_alloc(pktmbuf_pool);
513 printf("rte_pktmbuf_alloc() failed (%u)\n", i);
519 for (i=0; i<NB_MBUF; i++) {
521 struct rte_mbuf *mb, *mt;
527 rte_pktmbuf_free_seg(mt);
536 * Stress test for rte_mbuf atomic refcnt.
537 * Implies that RTE_MBUF_REFCNT_ATOMIC is defined.
538 * For more efficency, recomended to run with RTE_LIBRTE_MBUF_DEBUG defined.
541 #ifdef RTE_MBUF_REFCNT_ATOMIC
544 test_refcnt_slave(__attribute__((unused)) void *arg)
546 unsigned lcore, free;
549 lcore = rte_lcore_id();
550 printf("%s started at lcore %u\n", __func__, lcore);
553 while (refcnt_stop_slaves == 0) {
554 if (rte_ring_dequeue(refcnt_mbuf_ring, &mp) == 0) {
556 rte_pktmbuf_free((struct rte_mbuf *)mp);
560 refcnt_lcore[lcore] += free;
561 printf("%s finished at lcore %u, "
562 "number of freed mbufs: %u\n",
563 __func__, lcore, free);
568 test_refcnt_iter(unsigned lcore, unsigned iter)
571 unsigned i, n, tref, wn;
576 /* For each mbuf in the pool:
578 * - increment it's reference up to N+1,
579 * - enqueue it N times into the ring for slave cores to free.
581 for (i = 0, n = rte_mempool_count(refcnt_pool);
582 i != n && (m = rte_pktmbuf_alloc(refcnt_pool)) != NULL;
584 ref = RTE_MAX(rte_rand() % REFCNT_MAX_REF, 1UL);
586 if ((ref & 1) != 0) {
587 rte_pktmbuf_refcnt_update(m, ref);
589 rte_ring_enqueue(refcnt_mbuf_ring, m);
592 rte_pktmbuf_refcnt_update(m, 1);
593 rte_ring_enqueue(refcnt_mbuf_ring, m);
600 rte_panic("(lcore=%u, iter=%u): was able to allocate only "
601 "%u from %u mbufs\n", lcore, iter, i, n);
603 /* wait till slave lcores will consume all mbufs */
604 while (!rte_ring_empty(refcnt_mbuf_ring))
607 /* check that all mbufs are back into mempool by now */
608 for (wn = 0; wn != REFCNT_MAX_TIMEOUT; wn++) {
609 if ((i = rte_mempool_count(refcnt_pool)) == n) {
610 refcnt_lcore[lcore] += tref;
611 printf("%s(lcore=%u, iter=%u) completed, "
612 "%u references processed\n",
613 __func__, lcore, iter, tref);
619 rte_panic("(lcore=%u, iter=%u): after %us only "
620 "%u of %u mbufs left free\n", lcore, iter, wn, i, n);
624 test_refcnt_master(void)
628 lcore = rte_lcore_id();
629 printf("%s started at lcore %u\n", __func__, lcore);
631 for (i = 0; i != REFCNT_MAX_ITER; i++)
632 test_refcnt_iter(lcore, i);
634 refcnt_stop_slaves = 1;
637 printf("%s finished at lcore %u\n", __func__, lcore);
644 test_refcnt_mbuf(void)
646 #ifdef RTE_MBUF_REFCNT_ATOMIC
648 unsigned lnum, master, slave, tref;
651 if ((lnum = rte_lcore_count()) == 1) {
652 printf("skipping %s, number of lcores: %u is not enough\n",
657 printf("starting %s, at %u lcores\n", __func__, lnum);
659 /* create refcnt pool & ring if they don't exist */
661 if (refcnt_pool == NULL &&
662 (refcnt_pool = rte_pktmbuf_pool_create(
663 MAKE_STRING(refcnt_pool),
664 REFCNT_MBUF_NUM, 0, 0, 0,
665 SOCKET_ID_ANY)) == NULL) {
666 printf("%s: cannot allocate " MAKE_STRING(refcnt_pool) "\n",
671 if (refcnt_mbuf_ring == NULL &&
672 (refcnt_mbuf_ring = rte_ring_create("refcnt_mbuf_ring",
673 REFCNT_RING_SIZE, SOCKET_ID_ANY,
674 RING_F_SP_ENQ)) == NULL) {
675 printf("%s: cannot allocate " MAKE_STRING(refcnt_mbuf_ring)
680 refcnt_stop_slaves = 0;
681 memset(refcnt_lcore, 0, sizeof (refcnt_lcore));
683 rte_eal_mp_remote_launch(test_refcnt_slave, NULL, SKIP_MASTER);
685 test_refcnt_master();
687 rte_eal_mp_wait_lcore();
689 /* check that we porcessed all references */
691 master = rte_get_master_lcore();
693 RTE_LCORE_FOREACH_SLAVE(slave)
694 tref += refcnt_lcore[slave];
696 if (tref != refcnt_lcore[master])
697 rte_panic("refernced mbufs: %u, freed mbufs: %u\n",
698 tref, refcnt_lcore[master]);
700 rte_mempool_dump(stdout, refcnt_pool);
701 rte_ring_dump(stdout, refcnt_mbuf_ring);
708 #include <sys/wait.h>
710 /* use fork() to test mbuf errors panic */
712 verify_mbuf_check_panics(struct rte_mbuf *buf)
720 rte_mbuf_sanity_check(buf, 1); /* should panic */
721 exit(0); /* return normally if it doesn't panic */
723 printf("Fork Failed\n");
734 test_failing_mbuf_sanity_check(void)
736 struct rte_mbuf *buf;
737 struct rte_mbuf badbuf;
739 printf("Checking rte_mbuf_sanity_check for failure conditions\n");
741 /* get a good mbuf to use to make copies */
742 buf = rte_pktmbuf_alloc(pktmbuf_pool);
745 printf("Checking good mbuf initially\n");
746 if (verify_mbuf_check_panics(buf) != -1)
749 printf("Now checking for error conditions\n");
751 if (verify_mbuf_check_panics(NULL)) {
752 printf("Error with NULL mbuf test\n");
758 if (verify_mbuf_check_panics(&badbuf)) {
759 printf("Error with bad-pool mbuf test\n");
764 badbuf.buf_physaddr = 0;
765 if (verify_mbuf_check_panics(&badbuf)) {
766 printf("Error with bad-physaddr mbuf test\n");
771 badbuf.buf_addr = NULL;
772 if (verify_mbuf_check_panics(&badbuf)) {
773 printf("Error with bad-addr mbuf test\n");
779 if (verify_mbuf_check_panics(&badbuf)) {
780 printf("Error with bad-refcnt(0) mbuf test\n");
785 badbuf.refcnt = UINT16_MAX;
786 if (verify_mbuf_check_panics(&badbuf)) {
787 printf("Error with bad-refcnt(MAX) mbuf test\n");
798 RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_SIZE * 2);
800 /* create pktmbuf pool if it does not exist */
801 if (pktmbuf_pool == NULL) {
802 pktmbuf_pool = rte_pktmbuf_pool_create("test_pktmbuf_pool",
803 NB_MBUF, 32, 0, MBUF_DATA_SIZE, SOCKET_ID_ANY);
806 if (pktmbuf_pool == NULL) {
807 printf("cannot allocate mbuf pool\n");
811 /* test multiple mbuf alloc */
812 if (test_pktmbuf_pool() < 0) {
813 printf("test_mbuf_pool() failed\n");
817 /* do it another time to check that all mbufs were freed */
818 if (test_pktmbuf_pool() < 0) {
819 printf("test_mbuf_pool() failed (2)\n");
823 /* test that the pointer to the data on a packet mbuf is set properly */
824 if (test_pktmbuf_pool_ptr() < 0) {
825 printf("test_pktmbuf_pool_ptr() failed\n");
829 /* test data manipulation in mbuf */
830 if (test_one_pktmbuf() < 0) {
831 printf("test_one_mbuf() failed\n");
837 * do it another time, to check that allocation reinitialize
840 if (test_one_pktmbuf() < 0) {
841 printf("test_one_mbuf() failed (2)\n");
845 if (test_pktmbuf_with_non_ascii_data() < 0) {
846 printf("test_pktmbuf_with_non_ascii_data() failed\n");
850 /* test free pktmbuf segment one by one */
851 if (test_pktmbuf_free_segment() < 0) {
852 printf("test_pktmbuf_free_segment() failed.\n");
856 if (testclone_testupdate_testdetach()<0){
857 printf("testclone_and_testupdate() failed \n");
861 if (test_refcnt_mbuf()<0){
862 printf("test_refcnt_mbuf() failed \n");
866 if (test_failing_mbuf_sanity_check() < 0) {
867 printf("test_failing_mbuf_sanity_check() failed\n");
873 static struct test_command mbuf_cmd = {
874 .command = "mbuf_autotest",
875 .callback = test_mbuf,
877 REGISTER_TEST_COMMAND(mbuf_cmd);