| 1004 | } |
| 1005 | |
| 1006 | int |
| 1007 | init_mem(uint16_t portid, unsigned int nb_mbuf) |
| 1008 | { |
| 1009 | #ifdef RTE_LIB_EVENTDEV |
| 1010 | struct l3fwd_event_resources *evt_rsrc = l3fwd_get_eventdev_rsrc(); |
| 1011 | #endif |
| 1012 | struct lcore_conf *qconf; |
| 1013 | int socketid; |
| 1014 | unsigned lcore_id; |
| 1015 | char s[64]; |
| 1016 | |
| 1017 | for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { |
| 1018 | if (rte_lcore_is_enabled(lcore_id) == 0) |
| 1019 | continue; |
| 1020 | |
| 1021 | if (numa_on) |
| 1022 | socketid = rte_lcore_to_socket_id(lcore_id); |
| 1023 | else |
| 1024 | socketid = 0; |
| 1025 | |
| 1026 | if (socketid >= NB_SOCKETS) { |
| 1027 | rte_exit(EXIT_FAILURE, |
| 1028 | "Socket %d of lcore %u is out of range %d\n", |
| 1029 | socketid, lcore_id, NB_SOCKETS); |
| 1030 | } |
| 1031 | |
| 1032 | if (pktmbuf_pool[portid][socketid] == NULL) { |
| 1033 | snprintf(s, sizeof(s), "mbuf_pool_%d:%d", |
| 1034 | portid, socketid); |
| 1035 | pktmbuf_pool[portid][socketid] = |
| 1036 | rte_pktmbuf_pool_create(s, nb_mbuf, |
| 1037 | MEMPOOL_CACHE_SIZE, 0, |
| 1038 | RTE_MBUF_DEFAULT_BUF_SIZE, socketid); |
| 1039 | if (pktmbuf_pool[portid][socketid] == NULL) |
| 1040 | rte_exit(EXIT_FAILURE, |
| 1041 | "Cannot init mbuf pool on socket %d\n", |
| 1042 | socketid); |
| 1043 | else |
| 1044 | printf("Allocated mbuf pool on socket %d\n", |
| 1045 | socketid); |
| 1046 | |
| 1047 | /* Setup ACL, LPM, EM(f.e Hash) or FIB. But, only once per |
| 1048 | * available socket. |
| 1049 | */ |
| 1050 | if (!lkp_per_socket[socketid]) { |
| 1051 | l3fwd_lkp.setup(socketid); |
| 1052 | lkp_per_socket[socketid] = 1; |
| 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | #ifdef RTE_LIB_EVENTDEV |
| 1057 | if (evt_rsrc->vector_enabled && vector_pool[portid] == NULL) { |
| 1058 | unsigned int nb_vec; |
| 1059 | |
| 1060 | nb_vec = (nb_mbuf + evt_rsrc->vector_size - 1) / |
| 1061 | evt_rsrc->vector_size; |
| 1062 | nb_vec = RTE_MAX(512U, nb_vec); |
| 1063 | nb_vec += rte_lcore_count() * 32; |
no test coverage detected