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

Function test_pktmbuf_alloc_bulk

dpdk/app/test/test_mbuf.c:1835–1867  ·  view source on GitHub ↗

* Test for allocating a bulk of mbufs * define an array with positive sizes for mbufs allocations. */

Source from the content-addressed store, hash-verified

1833 * define an array with positive sizes for mbufs allocations.
1834 */
1835static int
1836test_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

Callers 2

test_mbufFunction · 0.85

Calls 3

rte_pktmbuf_alloc_bulkFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected