* Test for allocating a bulk of mbufs * define an array with positive sizes for mbufs allocations. */
| 1833 | * define an array with positive sizes for mbufs allocations. |
| 1834 | */ |
| 1835 | static int |
| 1836 | test_pktmbuf_alloc_bulk(struct rte_mempool *pktmbuf_pool) |
| 1837 | { |
| 1838 | int ret = 0; |
| 1839 | unsigned int idx, loop; |
| 1840 | unsigned int alloc_counts[] = { |
| 1841 | 0, |
| 1842 | MEMPOOL_CACHE_SIZE - 1, |
| 1843 | MEMPOOL_CACHE_SIZE + 1, |
| 1844 | MEMPOOL_CACHE_SIZE * 1.5, |
| 1845 | MEMPOOL_CACHE_SIZE * 2, |
| 1846 | MEMPOOL_CACHE_SIZE * 2 - 1, |
| 1847 | MEMPOOL_CACHE_SIZE * 2 + 1, |
| 1848 | MEMPOOL_CACHE_SIZE, |
| 1849 | }; |
| 1850 | |
| 1851 | /* allocate a large array of mbuf pointers */ |
| 1852 | struct rte_mbuf *mbufs[NB_MBUF] = { 0 }; |
| 1853 | for (idx = 0; idx < RTE_DIM(alloc_counts); idx++) { |
| 1854 | ret = rte_pktmbuf_alloc_bulk(pktmbuf_pool, mbufs, |
| 1855 | alloc_counts[idx]); |
| 1856 | if (ret == 0) { |
| 1857 | for (loop = 0; loop < alloc_counts[idx] && |
| 1858 | mbufs[loop] != NULL; loop++) |
| 1859 | rte_pktmbuf_free(mbufs[loop]); |
| 1860 | } else if (ret != 0) { |
| 1861 | printf("%s: Bulk alloc failed count(%u); ret val(%d)\n", |
| 1862 | __func__, alloc_counts[idx], ret); |
| 1863 | return -1; |
| 1864 | } |
| 1865 | } |
| 1866 | return 0; |
| 1867 | } |
| 1868 | |
| 1869 | /* |
| 1870 | * Negative testing for allocating a bulk of mbufs |
no test coverage detected