@@ -415,7 +415,13 @@ init_lcore_conf(void)
415415 }
416416
417417 ff_cur_lcore_conf ()-> port_cfgs = ff_global_cfg .dpdk .port_cfgs ;
418- ff_cur_lcore_conf ()-> proc_id = ff_global_cfg .dpdk .proc_id ;
418+ if (ff_global_cfg .dpdk .thread_mode ) {
419+ int ti ;
420+ for (ti = 0 ; ti < ff_global_cfg .dpdk .nb_threads ; ti ++ )
421+ lcore_conf [ff_global_cfg .dpdk .proc_lcore [ti ]].proc_id = ti ;
422+ } else {
423+ ff_cur_lcore_conf ()-> proc_id = ff_global_cfg .dpdk .proc_id ;
424+ }
419425
420426 uint16_t socket_id = 0 ;
421427 if (numa_on ) {
@@ -649,13 +655,15 @@ static int
649655init_msg_ring (void )
650656{
651657 uint16_t i , j ;
652- uint16_t nb_procs = ff_global_cfg .dpdk .nb_procs ;
658+ uint16_t nb_rings = ff_global_cfg .dpdk .thread_mode
659+ ? ff_global_cfg .dpdk .nb_threads
660+ : ff_global_cfg .dpdk .nb_procs ;
653661 unsigned socketid = ff_cur_lcore_conf ()-> socket_id ;
654662
655663 /* Create message buffer pool */
656664 if (rte_eal_process_type () == RTE_PROC_PRIMARY ) {
657665 message_pool = rte_mempool_create (FF_MSG_POOL ,
658- MSG_RING_SIZE * 2 * nb_procs ,
666+ MSG_RING_SIZE * 2 * nb_rings ,
659667 MAX_MSG_BUF_SIZE , MSG_RING_SIZE / 2 , 0 ,
660668 NULL , NULL , ff_msg_init , NULL ,
661669 socketid , 0 );
@@ -667,7 +675,7 @@ init_msg_ring(void)
667675 rte_panic ("Create msg mempool failed\n" );
668676 }
669677
670- for (i = 0 ; i < nb_procs ; ++ i ) {
678+ for (i = 0 ; i < nb_rings ; ++ i ) {
671679 snprintf (msg_ring [i ].ring_name [0 ], RTE_RING_NAMESIZE ,
672680 "%s%u" , FF_MSG_RING_IN , i );
673681 msg_ring [i ].ring [0 ] = create_ring (msg_ring [i ].ring_name [0 ],
@@ -771,7 +779,7 @@ init_port_start(void)
771779
772780 total_nb_ports = nb_ports ;
773781#ifdef FF_KNI
774- if (enable_kni && rte_eal_process_type () == RTE_PROC_PRIMARY ) {
782+ if (enable_kni && ff_kni_is_owner_thread () ) {
775783 total_nb_ports *= 2 ; /* one more virtio_user port for kernel per port */
776784 }
777785#endif
@@ -2007,7 +2015,7 @@ process_packets(uint16_t port_id, uint16_t queue_id, struct rte_mbuf **bufs,
20072015 }
20082016
20092017#ifdef FF_KNI
2010- if (enable_kni && rte_eal_process_type () == RTE_PROC_PRIMARY ) {
2018+ if (enable_kni && ff_kni_is_owner_thread () ) {
20112019 mbuf_pool = pktmbuf_pool [qconf -> socket_id ];
20122020 mbuf_clone = pktmbuf_deep_clone (rtem , mbuf_pool );
20132021 if (mbuf_clone ) {
@@ -2018,7 +2026,8 @@ process_packets(uint16_t port_id, uint16_t queue_id, struct rte_mbuf **bufs,
20182026#endif
20192027 ff_veth_input (ctx , rtem );
20202028#ifdef FF_KNI
2021- } else if (enable_kni ) {
2029+ } else if (enable_kni &&
2030+ (!ff_global_cfg .dpdk .thread_mode || ff_kni_is_owner_thread ())) {
20222031 if (knictl_action == FF_KNICTL_ACTION_ALL_TO_KNI ){
20232032 ff_add_vlan_tag (rtem );
20242033 ff_kni_enqueue (filter , port_id , rtem );
@@ -2666,7 +2675,7 @@ main_loop(void *arg)
26662675 ctx = veth_ctx [port_id ];
26672676
26682677#ifdef FF_KNI
2669- if (enable_kni && rte_eal_process_type () == RTE_PROC_PRIMARY ) {
2678+ if (enable_kni && ff_kni_is_owner_thread () ) {
26702679 ff_kni_process (port_id , queue_id , pkts_burst , MAX_PKT_BURST );
26712680 }
26722681#endif
0 commit comments