MCPcopy Index your code
hub / github.com/F-Stack/f-stack / init_mem_pool

Function init_mem_pool

lib/ff_dpdk_if.c:328–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326}
327
328static int
329init_mem_pool(void)
330{
331 uint8_t nb_ports = ff_global_cfg.dpdk.nb_ports;
332 uint32_t nb_lcores = ff_global_cfg.dpdk.nb_procs;
333 uint32_t nb_tx_queue = nb_lcores;
334 uint32_t nb_rx_queue = lcore_conf.nb_rx_queue * nb_lcores;
335 uint16_t max_portid = ff_global_cfg.dpdk.max_portid;
336
337 unsigned nb_mbuf = RTE_ALIGN_CEIL (
338 (nb_rx_queue * (max_portid + 1) * 2 * RX_QUEUE_SIZE +
339 nb_ports * (max_portid + 1) * 2 * nb_lcores * MAX_PKT_BURST +
340 nb_ports * (max_portid + 1) * 2 * nb_tx_queue * TX_QUEUE_SIZE +
341 nb_lcores * MEMPOOL_CACHE_SIZE +
342#ifdef FF_KNI
343 nb_ports * KNI_MBUF_MAX +
344 nb_ports * KNI_QUEUE_SIZE +
345#endif
346 nb_lcores * nb_ports * DISPATCH_RING_SIZE),
347 (unsigned)8192);
348
349 unsigned socketid = 0;
350 uint16_t i, lcore_id;
351 char s[64];
352
353 for (i = 0; i < ff_global_cfg.dpdk.nb_procs; i++) {
354 lcore_id = ff_global_cfg.dpdk.proc_lcore[i];
355 if (numa_on) {
356 socketid = rte_lcore_to_socket_id(lcore_id);
357 }
358
359 if (socketid >= NB_SOCKETS) {
360 rte_exit(EXIT_FAILURE, "Socket %d of lcore %u is out of range %d\n",
361 socketid, i, NB_SOCKETS);
362 }
363
364 if (pktmbuf_pool[socketid] != NULL) {
365 continue;
366 }
367
368 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
369 snprintf(s, sizeof(s), "mbuf_pool_%d", socketid);
370 pktmbuf_pool[socketid] =
371 rte_pktmbuf_pool_create(s, nb_mbuf,
372 MEMPOOL_CACHE_SIZE, 0,
373 RTE_MBUF_DEFAULT_BUF_SIZE, socketid);
374 } else {
375 snprintf(s, sizeof(s), "mbuf_pool_%d", socketid);
376 pktmbuf_pool[socketid] = rte_mempool_lookup(s);
377 }
378
379 if (pktmbuf_pool[socketid] == NULL) {
380 rte_exit(EXIT_FAILURE, "Cannot create mbuf pool on socket %d\n", socketid);
381 } else {
382 ff_log(FF_LOG_INFO, FF_LOGTYPE_FSTACK_LIB, "create mbuf pool on socket %d\n", socketid);
383 }
384
385#ifdef FF_USE_PAGE_ARRAY

Callers 1

ff_dpdk_initFunction · 0.85

Calls 8

rte_lcore_to_socket_idFunction · 0.85
rte_exitFunction · 0.85
rte_eal_process_typeFunction · 0.85
snprintfFunction · 0.85
rte_pktmbuf_pool_createFunction · 0.85
rte_mempool_lookupFunction · 0.85
ff_logFunction · 0.85
ff_init_ref_poolFunction · 0.85

Tested by

no test coverage detected