| 2749 | } |
| 2750 | |
| 2751 | static int |
| 2752 | test_mbuf(void) |
| 2753 | { |
| 2754 | int ret = -1; |
| 2755 | struct rte_mempool *pktmbuf_pool = NULL; |
| 2756 | struct rte_mempool *pktmbuf_pool2 = NULL; |
| 2757 | |
| 2758 | |
| 2759 | RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) != RTE_CACHE_LINE_MIN_SIZE * 2); |
| 2760 | |
| 2761 | /* create pktmbuf pool if it does not exist */ |
| 2762 | pktmbuf_pool = rte_pktmbuf_pool_create("test_pktmbuf_pool", |
| 2763 | NB_MBUF, MEMPOOL_CACHE_SIZE, 0, MBUF_DATA_SIZE, |
| 2764 | SOCKET_ID_ANY); |
| 2765 | |
| 2766 | if (pktmbuf_pool == NULL) { |
| 2767 | printf("cannot allocate mbuf pool\n"); |
| 2768 | goto err; |
| 2769 | } |
| 2770 | |
| 2771 | /* test registration of dynamic fields and flags */ |
| 2772 | if (test_mbuf_dyn(pktmbuf_pool) < 0) { |
| 2773 | printf("mbuf dynflag test failed\n"); |
| 2774 | goto err; |
| 2775 | } |
| 2776 | |
| 2777 | /* create a specific pktmbuf pool with a priv_size != 0 and no data |
| 2778 | * room size */ |
| 2779 | pktmbuf_pool2 = rte_pktmbuf_pool_create("test_pktmbuf_pool2", |
| 2780 | NB_MBUF, MEMPOOL_CACHE_SIZE, MBUF2_PRIV_SIZE, 0, |
| 2781 | SOCKET_ID_ANY); |
| 2782 | |
| 2783 | if (pktmbuf_pool2 == NULL) { |
| 2784 | printf("cannot allocate mbuf pool\n"); |
| 2785 | goto err; |
| 2786 | } |
| 2787 | |
| 2788 | /* test multiple mbuf alloc */ |
| 2789 | if (test_pktmbuf_pool(pktmbuf_pool) < 0) { |
| 2790 | printf("test_mbuf_pool() failed\n"); |
| 2791 | goto err; |
| 2792 | } |
| 2793 | |
| 2794 | /* do it another time to check that all mbufs were freed */ |
| 2795 | if (test_pktmbuf_pool(pktmbuf_pool) < 0) { |
| 2796 | printf("test_mbuf_pool() failed (2)\n"); |
| 2797 | goto err; |
| 2798 | } |
| 2799 | |
| 2800 | /* test bulk mbuf alloc and free */ |
| 2801 | if (test_pktmbuf_pool_bulk() < 0) { |
| 2802 | printf("test_pktmbuf_pool_bulk() failed\n"); |
| 2803 | goto err; |
| 2804 | } |
| 2805 | |
| 2806 | /* test that the pointer to the data on a packet mbuf is set properly */ |
| 2807 | if (test_pktmbuf_pool_ptr(pktmbuf_pool) < 0) { |
| 2808 | printf("test_pktmbuf_pool_ptr() failed\n"); |
nothing calls this directly
no test coverage detected