8787#include "ans_kni.h"
8888
8989static struct ans_user_config ans_user_conf ;
90- static struct ans_lcore_queue ans_lcore_conf [RTE_MAX_LCORE ];
90+ static struct ans_lcore_queue g_lcore_queue [RTE_MAX_LCORE ];
9191static struct rte_mempool * ans_pktmbuf_pool [MAX_NB_SOCKETS ];
9292
9393static struct ans_lcore_params ans_lcore_params_default [] =
@@ -372,6 +372,34 @@ static uint8_t ans_get_port_rx_queues_nb(const uint8_t port, struct ans_user_con
372372 }
373373 return (uint8_t )(++ queue );
374374}
375+ /**********************************************************************
376+ *@description:
377+ *
378+ *
379+ *@parameters:
380+ * [in]:
381+ * [in]:
382+ *
383+ *@return values:
384+ *
385+ **********************************************************************/
386+ static uint8_t ans_get_port_rx_qmapping (const uint8_t port , uint8_t qmapping_size , struct ans_port_qmapping * qmapping , struct ans_user_config * user_conf )
387+ {
388+ uint16_t i ;
389+ uint8_t queue_nb = 0 ;
390+
391+ for (i = 0 ; i < user_conf -> lcore_param_nb && queue_nb < qmapping_size ; ++ i )
392+ {
393+ if (user_conf -> lcore_param [i ].port_id == port )
394+ {
395+ qmapping [queue_nb ].lcore_id = user_conf -> lcore_param [i ].lcore_id ;
396+ qmapping [queue_nb ].queue_id = user_conf -> lcore_param [i ].queue_id ;
397+ queue_nb ++ ;
398+ }
399+ }
400+
401+ return (queue_nb );
402+ }
375403
376404/**********************************************************************
377405*@description:
@@ -625,7 +653,7 @@ static inline int ans_send_packet(uint8_t port, struct rte_mbuf *m)
625653 struct ans_lcore_queue * qconf ;
626654 struct ans_tx_queue * tx_queue ;
627655
628- qconf = & ans_lcore_conf [rte_lcore_id ()];
656+ qconf = & g_lcore_queue [rte_lcore_id ()];
629657
630658 tx_queue = & qconf -> tx_queue [port ];
631659
@@ -715,7 +743,7 @@ static int ans_main_loop(__attribute__((unused)) void *dummy)
715743 prev_tsc = 0 ;
716744
717745 lcore_id = rte_lcore_id ();
718- qconf = & ans_lcore_conf [lcore_id ];
746+ qconf = & g_lcore_queue [lcore_id ];
719747
720748 if (qconf -> n_rx_queue == 0 )
721749 {
@@ -825,7 +853,7 @@ int main(int argc, char **argv)
825853 int s ;
826854
827855 memset (& ans_user_conf , 0 , sizeof (ans_user_conf ));
828- memset (ans_lcore_conf , 0 , sizeof (ans_lcore_conf ));
856+ memset (g_lcore_queue , 0 , sizeof (g_lcore_queue ));
829857
830858 ans_user_conf .numa_on = 1 ;
831859 ans_user_conf .lcore_param_nb = sizeof (ans_lcore_params_default ) / sizeof (ans_lcore_params_default [0 ]);
@@ -871,7 +899,7 @@ int main(int argc, char **argv)
871899 if (ans_check_lcore_params (& ans_user_conf ) < 0 )
872900 rte_exit (EXIT_FAILURE , "check_lcore_params failed\n" );
873901
874- ret = ans_init_lcore_rx_queues (& ans_user_conf , ans_lcore_conf );
902+ ret = ans_init_lcore_rx_queues (& ans_user_conf , g_lcore_queue );
875903 if (ret < 0 )
876904 rte_exit (EXIT_FAILURE , "init_lcore_rx_queues failed\n" );
877905
@@ -885,14 +913,14 @@ int main(int argc, char **argv)
885913 rte_exit (EXIT_FAILURE , "check_port_config failed\n" );
886914
887915
888- ret = ans_init_ports (nb_ports , & ans_user_conf , ans_lcore_conf );
916+ ret = ans_init_ports (nb_ports , & ans_user_conf , g_lcore_queue );
889917 if (ret < 0 )
890918 rte_exit (EXIT_FAILURE , "Init ports failed\n" );
891919
892920
893921 /* add by ans_team: support KNI interface at 2014-12-15 */
894922 if (ans_user_conf .kni_on == 1 )
895- ans_kni_config (& ans_user_conf , ans_lcore_conf , ans_pktmbuf_pool );
923+ ans_kni_config (& ans_user_conf , g_lcore_queue , ans_pktmbuf_pool );
896924
897925
898926 /* add by ans_team ---start */
@@ -923,7 +951,9 @@ int main(int argc, char **argv)
923951 int portid ;
924952 uint16_t kni_id ;
925953 struct ether_addr eth_addr ;
926-
954+ uint16_t qmapping_nb ;
955+ struct ans_port_qmapping qmapping [32 ];
956+
927957 for (portid = 0 ; portid < nb_ports ; portid ++ )
928958 {
929959 /* skip ports that are not enabled */
@@ -943,6 +973,11 @@ int main(int argc, char **argv)
943973
944974 ans_iface_add (portid , kni_id , ifname , & eth_addr );
945975
976+ /* set port rx queue mapping */
977+ qmapping_nb = ans_get_port_rx_qmapping (portid , 32 , qmapping , & ans_user_conf );
978+
979+ ans_iface_set_queue (ifname , qmapping_nb , qmapping );
980+
946981 /* host byte order */
947982 int ip_addr = 0x0a000002 ;
948983 ip_addr += portid << 16 ;
0 commit comments