| 475 | } |
| 476 | |
| 477 | static int |
| 478 | init_msg_ring(void) |
| 479 | { |
| 480 | uint16_t i, j; |
| 481 | uint16_t nb_procs = ff_global_cfg.dpdk.nb_procs; |
| 482 | unsigned socketid = lcore_conf.socket_id; |
| 483 | |
| 484 | /* Create message buffer pool */ |
| 485 | if (rte_eal_process_type() == RTE_PROC_PRIMARY) { |
| 486 | message_pool = rte_mempool_create(FF_MSG_POOL, |
| 487 | MSG_RING_SIZE * 2 * nb_procs, |
| 488 | MAX_MSG_BUF_SIZE, MSG_RING_SIZE / 2, 0, |
| 489 | NULL, NULL, ff_msg_init, NULL, |
| 490 | socketid, 0); |
| 491 | } else { |
| 492 | message_pool = rte_mempool_lookup(FF_MSG_POOL); |
| 493 | } |
| 494 | |
| 495 | if (message_pool == NULL) { |
| 496 | rte_panic("Create msg mempool failed\n"); |
| 497 | } |
| 498 | |
| 499 | for(i = 0; i < nb_procs; ++i) { |
| 500 | snprintf(msg_ring[i].ring_name[0], RTE_RING_NAMESIZE, |
| 501 | "%s%u", FF_MSG_RING_IN, i); |
| 502 | msg_ring[i].ring[0] = create_ring(msg_ring[i].ring_name[0], |
| 503 | MSG_RING_SIZE, socketid, RING_F_SP_ENQ | RING_F_SC_DEQ); |
| 504 | if (msg_ring[i].ring[0] == NULL) |
| 505 | rte_panic("create ring::%s failed!\n", msg_ring[i].ring_name[0]); |
| 506 | |
| 507 | for (j = FF_SYSCTL; j < FF_MSG_NUM; j++) { |
| 508 | snprintf(msg_ring[i].ring_name[j], RTE_RING_NAMESIZE, |
| 509 | "%s%u_%u", FF_MSG_RING_OUT, i, j); |
| 510 | msg_ring[i].ring[j] = create_ring(msg_ring[i].ring_name[j], |
| 511 | MSG_RING_SIZE, socketid, RING_F_SP_ENQ | RING_F_SC_DEQ); |
| 512 | if (msg_ring[i].ring[j] == NULL) |
| 513 | rte_panic("create ring::%s failed!\n", msg_ring[i].ring_name[j]); |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | return 0; |
| 518 | } |
| 519 | |
| 520 | #ifdef FF_KNI |
| 521 |
no test coverage detected