Skip to content

Commit eed943b

Browse files
committed
support flow filter and port queue mapping
1 parent b0665e3 commit eed943b

22 files changed

+84
-9
lines changed

ans/ans_main.c

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
#include "ans_kni.h"
8888

8989
static 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];
9191
static struct rte_mempool *ans_pktmbuf_pool[MAX_NB_SOCKETS];
9292

9393
static 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;

doc/guides/ans_user_guide.pdf

9.67 KB
Binary file not shown.

librte_ans/include/ans_errno.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,9 @@
388388
#define ANS_EADDRESS 3002 /* Add ip address failed */
389389
#define ANS_ENEIGHBOR 3003 /* Add neighbor route failed */
390390
#define ANS_EACL 3004 /* Add ACL failed */
391-
#define ANS_EBYPASS 3005 /* Add ACL failed */
391+
#define ANS_EBYPASS 3005 /* Add bypass rule failed */
392392
#define ANS_ENETLINK 3006 /* parse netlink message failed */
393+
#define ANS_EFFILTER 3007 /* Add flow filter rule failed */
393394

394395

395396
#define ANS_ERRMEM ANS_ENOMEM /* Out of memory error. */

librte_ans/include/ans_ip_intf.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@
7171
*
7272
*/
7373

74+
/*
75+
* define rx queue to lcore mapping
76+
*/
77+
struct ans_port_qmapping
78+
{
79+
uint8_t queue_id;
80+
uint8_t lcore_id;
81+
};
82+
7483
/**
7584
* Handle the received packets by ans stack
7685
*
@@ -155,6 +164,36 @@ int ans_iface_get_mtu(char *if_name, uint16_t *mtu);
155164
*/
156165
int ans_iface_set_mtu(char *if_name, uint16_t mtu);
157166

167+
/**
168+
* Retrieves rx queue to lcore mapping for an interface.
169+
*
170+
* @param name
171+
* name of the interface for which the queue mapping is retrieved
172+
* @param qmapping_nb
173+
* queue_mapping array size, and also return the queue mapping number.
174+
* @param qmapping
175+
* rx queue to lcore mapping
176+
*
177+
* @return 0 - SUCCESS, non-zero - FAILURE
178+
*
179+
*/
180+
int ans_iface_get_queue(char *if_name, uint8_t *qmapping_nb, struct ans_port_qmapping *qmapping);
181+
182+
183+
/**
184+
* Set rx queue to lcore mapping for an interface.
185+
*
186+
* @param name
187+
* name of the interface for which the queue mapping is retrieved
188+
* @param qmapping_nb
189+
* queue_mapping array size.
190+
* @param qmapping
191+
* rx queue to lcore mapping
192+
*
193+
* @return 0 - SUCCESS, non-zero - FAILURE
194+
*
195+
*/
196+
int ans_iface_set_queue(char *if_name, uint8_t qmapping_nb, struct ans_port_qmapping *qmapping);
158197

159198
/**
160199
* Routing table addition.

librte_ans/librte_ans_broadwell.a

5.02 KB
Binary file not shown.

librte_ans/librte_ans_core2.a

5.08 KB
Binary file not shown.

librte_ans/librte_ans_haswell.a

5.02 KB
Binary file not shown.

librte_ans/librte_ans_ivybridge.a

5.08 KB
Binary file not shown.
5.08 KB
Binary file not shown.

librte_ans/librte_ans_westmere.a

5.08 KB
Binary file not shown.

0 commit comments

Comments
 (0)