MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_attach_from_different_pool

Function test_attach_from_different_pool

dpdk/app/test/test_mbuf.c:577–679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

575}
576
577static int
578test_attach_from_different_pool(struct rte_mempool *pktmbuf_pool,
579 struct rte_mempool *pktmbuf_pool2)
580{
581 struct rte_mbuf *m = NULL;
582 struct rte_mbuf *clone = NULL;
583 struct rte_mbuf *clone2 = NULL;
584 char *data, *c_data, *c_data2;
585
586 /* alloc a mbuf */
587 m = rte_pktmbuf_alloc(pktmbuf_pool);
588 if (m == NULL)
589 GOTO_FAIL("cannot allocate mbuf");
590
591 if (rte_pktmbuf_pkt_len(m) != 0)
592 GOTO_FAIL("Bad length");
593
594 data = rte_pktmbuf_mtod(m, char *);
595
596 /* allocate a new mbuf from the second pool, and attach it to the first
597 * mbuf */
598 clone = rte_pktmbuf_alloc(pktmbuf_pool2);
599 if (clone == NULL)
600 GOTO_FAIL("cannot allocate mbuf from second pool\n");
601
602 /* check data room size and priv size, and erase priv */
603 if (rte_pktmbuf_data_room_size(clone->pool) != 0)
604 GOTO_FAIL("data room size should be 0\n");
605 if (rte_pktmbuf_priv_size(clone->pool) != MBUF2_PRIV_SIZE)
606 GOTO_FAIL("data room size should be %d\n", MBUF2_PRIV_SIZE);
607 memset(clone + 1, 0, MBUF2_PRIV_SIZE);
608
609 /* save data pointer to compare it after detach() */
610 c_data = rte_pktmbuf_mtod(clone, char *);
611 if (c_data != (char *)clone + sizeof(*clone) + MBUF2_PRIV_SIZE)
612 GOTO_FAIL("bad data pointer in clone");
613 if (rte_pktmbuf_headroom(clone) != 0)
614 GOTO_FAIL("bad headroom in clone");
615
616 rte_pktmbuf_attach(clone, m);
617
618 if (rte_pktmbuf_mtod(clone, char *) != data)
619 GOTO_FAIL("clone was not attached properly\n");
620 if (rte_pktmbuf_headroom(clone) != RTE_PKTMBUF_HEADROOM)
621 GOTO_FAIL("bad headroom in clone after attach");
622 if (rte_mbuf_refcnt_read(m) != 2)
623 GOTO_FAIL("invalid refcnt in m\n");
624
625 /* allocate a new mbuf from the second pool, and attach it to the first
626 * cloned mbuf */
627 clone2 = rte_pktmbuf_alloc(pktmbuf_pool2);
628 if (clone2 == NULL)
629 GOTO_FAIL("cannot allocate clone2 from second pool\n");
630
631 /* check data room size and priv size, and erase priv */
632 if (rte_pktmbuf_data_room_size(clone2->pool) != 0)
633 GOTO_FAIL("data room size should be 0\n");
634 if (rte_pktmbuf_priv_size(clone2->pool) != MBUF2_PRIV_SIZE)

Callers 1

test_mbufFunction · 0.85

Calls 10

rte_pktmbuf_allocFunction · 0.85
rte_pktmbuf_priv_sizeFunction · 0.85
memsetFunction · 0.85
rte_pktmbuf_headroomFunction · 0.85
rte_pktmbuf_attachFunction · 0.85
rte_mbuf_refcnt_readFunction · 0.85
rte_pktmbuf_detachFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected