@@ -289,8 +289,8 @@ static int ans_init_lcore_rx_queues(struct ans_user_config *user_conf, struct a
289
289
}
290
290
else
291
291
{
292
- lcore_conf [lcore ].rx_queue_list [nb_rx_queue ].port_id = user_conf -> lcore_param [i ].port_id ;
293
- lcore_conf [lcore ].rx_queue_list [nb_rx_queue ].queue_id = user_conf -> lcore_param [i ].queue_id ;
292
+ lcore_conf [lcore ].rx_queue [nb_rx_queue ].port_id = user_conf -> lcore_param [i ].port_id ;
293
+ lcore_conf [lcore ].rx_queue [nb_rx_queue ].queue_id = user_conf -> lcore_param [i ].queue_id ;
294
294
lcore_conf [lcore ].n_rx_queue ++ ;
295
295
}
296
296
}
@@ -474,7 +474,7 @@ static int ans_init_ports(unsigned short nb_ports, struct ans_user_config *user
474
474
if (ret < 0 )
475
475
rte_exit (EXIT_FAILURE , "rte_eth_tx_queue_setup: err=%d, " "port=%d\n" , ret , portid );
476
476
477
- lcore_conf [lcore_id ].tx_queue_id [portid ] = queueid ;
477
+ lcore_conf [lcore_id ].tx_queue [portid ]. queue_id = queueid ;
478
478
479
479
queueid ++ ;
480
480
}
@@ -503,8 +503,8 @@ static int ans_init_ports(unsigned short nb_ports, struct ans_user_config *user
503
503
/* init RX queues */
504
504
for (queue = 0 ; queue < lcore_conf [lcore_id ].n_rx_queue ; ++ queue )
505
505
{
506
- portid = lcore_conf [lcore_id ].rx_queue_list [queue ].port_id ;
507
- queueid = lcore_conf [lcore_id ].rx_queue_list [queue ].queue_id ;
506
+ portid = lcore_conf [lcore_id ].rx_queue [queue ].port_id ;
507
+ queueid = lcore_conf [lcore_id ].rx_queue [queue ].queue_id ;
508
508
509
509
if (user_conf -> numa_on )
510
510
socketid = (uint8_t )rte_lcore_to_socket_id (lcore_id );
@@ -590,25 +590,21 @@ static int ans_start_ports(unsigned short nb_ports, struct ans_user_config *use
590
590
*@return values:
591
591
*
592
592
**********************************************************************/
593
- static inline int ans_send_burst (struct ans_lcore_queue * qconf , uint16_t n , uint8_t port )
593
+ static inline int ans_send_burst (uint8_t port_id , uint16_t queue_id , struct rte_mbuf * * tx_pkts , uint16_t nb_pkts )
594
594
{
595
- struct rte_mbuf * * m_table ;
596
- int ret ;
597
- uint16_t queueid ;
598
-
599
- queueid = qconf -> tx_queue_id [port ];
600
- m_table = (struct rte_mbuf * * )qconf -> tx_mbufs [port ].m_table ;
595
+ uint16_t send_nb , left_nb ;
601
596
602
- ret = rte_eth_tx_burst (port , queueid , m_table , n );
603
- if (unlikely (ret < n ))
597
+ send_nb = rte_eth_tx_burst (port_id , queue_id , tx_pkts , nb_pkts );
598
+ if (unlikely (send_nb < nb_pkts ))
604
599
{
605
- ans_eth_stats (port , n - ret );
606
-
600
+ left_nb = send_nb ;
607
601
do
608
602
{
609
- rte_pktmbuf_free (m_table [ ret ]);
610
- } while (++ ret < n );
603
+ rte_pktmbuf_free (tx_pkts [ left_nb ]);
604
+ } while (++ left_nb < nb_pkts );
611
605
}
606
+
607
+ ans_eth_stats (port_id , nb_pkts , nb_pkts - send_nb );
612
608
613
609
return 0 ;
614
610
}
@@ -626,25 +622,22 @@ static inline int ans_send_burst(struct ans_lcore_queue *qconf, uint16_t n, uint
626
622
**********************************************************************/
627
623
static inline int ans_send_packet (uint8_t port , struct rte_mbuf * m )
628
624
{
629
- uint32_t lcore_id ;
630
- uint16_t len ;
631
625
struct ans_lcore_queue * qconf ;
626
+ struct ans_tx_queue * tx_queue ;
627
+
628
+ qconf = & ans_lcore_conf [rte_lcore_id ()];
632
629
633
- lcore_id = rte_lcore_id () ;
630
+ tx_queue = & qconf -> tx_queue [ port ] ;
634
631
635
- qconf = & ans_lcore_conf [lcore_id ];
636
- len = qconf -> tx_mbufs [port ].len ;
637
- qconf -> tx_mbufs [port ].m_table [len ] = m ;
638
- len ++ ;
632
+ tx_queue -> pkts [tx_queue -> pkts_nb ++ ] = m ;
639
633
640
- /* enough pkts to be sent */
641
- if (unlikely (len == MAX_TX_BURST ))
634
+ if (tx_queue -> pkts_nb == MAX_TX_BURST )
642
635
{
643
- ans_send_burst (qconf , MAX_TX_BURST , port );
644
- len = 0 ;
636
+ ans_send_burst (port , tx_queue -> queue_id , tx_queue -> pkts , tx_queue -> pkts_nb );
637
+
638
+ tx_queue -> pkts_nb = 0 ;
645
639
}
646
640
647
- qconf -> tx_mbufs [port ].len = len ;
648
641
return 0 ;
649
642
}
650
643
@@ -715,7 +708,8 @@ static int ans_main_loop(__attribute__((unused)) void *dummy)
715
708
struct ans_lcore_queue * qconf ;
716
709
uint64_t timer_prev_tsc = 0 , timer_cur_tsc , timer_diff_tsc ;
717
710
struct rte_mbuf * pkts_burst [MAX_PKT_BURST ];
718
-
711
+ struct ans_tx_queue * tx_queue ;
712
+ struct ans_rx_queue * rx_queue ;
719
713
const uint64_t drain_tsc = (rte_get_tsc_hz () + US_PER_S - 1 ) / US_PER_S * BURST_TX_DRAIN_US ;
720
714
721
715
prev_tsc = 0 ;
@@ -733,8 +727,8 @@ static int ans_main_loop(__attribute__((unused)) void *dummy)
733
727
734
728
for (i = 0 ; i < qconf -> n_rx_queue ; i ++ )
735
729
{
736
- portid = qconf -> rx_queue_list [i ].port_id ;
737
- queueid = qconf -> rx_queue_list [i ].queue_id ;
730
+ portid = qconf -> rx_queue [i ].port_id ;
731
+ queueid = qconf -> rx_queue [i ].queue_id ;
738
732
RTE_LOG (INFO , USER8 , " -- lcoreid=%u portid=%hhu rxqueueid=%hhu\n" , lcore_id , portid , queueid );
739
733
}
740
734
@@ -743,22 +737,20 @@ static int ans_main_loop(__attribute__((unused)) void *dummy)
743
737
744
738
while (1 )
745
739
{
746
-
747
- cur_tsc = rte_rdtsc ();
748
-
749
740
/* add by ans_team ---start */
750
741
ans_message_handle ();
751
742
/* add by ans_team ---end */
752
743
753
-
744
+ cur_tsc = rte_rdtsc ();
745
+ timer_cur_tsc = cur_tsc ;
746
+
754
747
/*
755
748
* Call the timer handler on each core: as we don't
756
749
* need a very precise timer, so only call
757
750
* rte_timer_manage() every ~10ms (at 2Ghz). In a real
758
751
* application, this will enhance performances as
759
752
* reading the HPET timer is not efficient.
760
753
*/
761
- timer_cur_tsc = rte_rdtsc ();
762
754
timer_diff_tsc = timer_cur_tsc - timer_prev_tsc ;
763
755
if (timer_diff_tsc > TIMER_RESOLUTION_CYCLES )
764
756
{
@@ -779,12 +771,12 @@ static int ans_main_loop(__attribute__((unused)) void *dummy)
779
771
*/
780
772
for (portid = 0 ; portid < nb_ports ; portid ++ )
781
773
{
782
- if (qconf -> tx_mbufs [portid ].len == 0 )
774
+ tx_queue = & qconf -> tx_queue [portid ];
775
+ if (tx_queue -> pkts_nb == 0 )
783
776
continue ;
784
777
785
- ans_send_burst (qconf , qconf -> tx_mbufs [portid ].len , portid );
786
-
787
- qconf -> tx_mbufs [portid ].len = 0 ;
778
+ ans_send_burst (portid , tx_queue -> queue_id , tx_queue -> pkts , tx_queue -> pkts_nb );
779
+ tx_queue -> pkts_nb = 0 ;
788
780
}
789
781
790
782
prev_tsc = cur_tsc ;
@@ -795,14 +787,13 @@ static int ans_main_loop(__attribute__((unused)) void *dummy)
795
787
*/
796
788
for (i = 0 ; i < qconf -> n_rx_queue ; ++ i )
797
789
{
798
- portid = qconf -> rx_queue_list [i ]. port_id ;
799
- queueid = qconf -> rx_queue_list [ i ]. queue_id ;
800
- nb_rx = rte_eth_rx_burst (portid , queueid , pkts_burst , MAX_PKT_BURST );
790
+ rx_queue = & qconf -> rx_queue [i ];
791
+
792
+ nb_rx = rte_eth_rx_burst (rx_queue -> port_id , rx_queue -> queue_id , pkts_burst , MAX_PKT_BURST );
801
793
if (nb_rx == 0 )
802
794
continue ;
803
795
804
- ans_eth_rx_burst (portid , pkts_burst , nb_rx );
805
-
796
+ ans_eth_rx_burst (rx_queue -> port_id , pkts_burst , nb_rx );
806
797
}
807
798
808
799
/* to support KNI, at 2014-12-15 */
0 commit comments