Skip to content

Commit 18bf7cc

Browse files
committed
improve l3 forwarding and alc performance
1 parent 0589228 commit 18bf7cc

16 files changed

+45
-80
lines changed

ans/ans_main.c

Lines changed: 25 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ static inline int ans_send_burst(struct ans_lcore_queue *qconf, uint16_t n, uint
602602
ret = rte_eth_tx_burst(port, queueid, m_table, n);
603603
if (unlikely(ret < n))
604604
{
605-
ans_packet_stats(port, n - ret);
605+
ans_eth_stats(port, n - ret);
606606

607607
do
608608
{
@@ -624,7 +624,7 @@ static inline int ans_send_burst(struct ans_lcore_queue *qconf, uint16_t n, uint
624624
*@return values:
625625
*
626626
**********************************************************************/
627-
static inline int ans_send_single_packet(struct rte_mbuf *m, uint8_t port)
627+
static inline int ans_send_packet(uint8_t port, struct rte_mbuf *m)
628628
{
629629
uint32_t lcore_id;
630630
uint16_t len;
@@ -659,11 +659,21 @@ static inline int ans_send_single_packet(struct rte_mbuf *m, uint8_t port)
659659
*@return values:
660660
*
661661
**********************************************************************/
662-
static void ans_init_timer()
662+
static inline int ans_bypass_packet(uint8_t port_id, struct rte_mbuf *m)
663663
{
664-
/* init RTE timer library */
665-
rte_timer_subsystem_init();
666-
return;
664+
int ret = 0;
665+
666+
if(ans_user_conf.kni_on != 1)
667+
{
668+
rte_pktmbuf_free(m);
669+
return 0 ;
670+
}
671+
672+
ret = ans_kni_send_burst(&m, 1, port_id);
673+
if(ret != 0 )
674+
rte_pktmbuf_free(m);
675+
676+
return 0;
667677
}
668678

669679
/**********************************************************************
@@ -677,20 +687,10 @@ static void ans_init_timer()
677687
*@return values:
678688
*
679689
**********************************************************************/
680-
static inline void ans_to_linux(unsigned port_id, struct rte_mbuf *m)
690+
static void ans_init_timer()
681691
{
682-
int ret = 0;
683-
684-
if(ans_user_conf.kni_on != 1)
685-
{
686-
rte_pktmbuf_free(m);
687-
return;
688-
}
689-
690-
ret = ans_kni_send_burst(&m, 1, port_id);
691-
if(ret != 0 )
692-
rte_pktmbuf_free(m);
693-
692+
/* init RTE timer library */
693+
rte_timer_subsystem_init();
694694
return;
695695
}
696696

@@ -707,7 +707,6 @@ static inline void ans_to_linux(unsigned port_id, struct rte_mbuf *m)
707707
**********************************************************************/
708708
static int ans_main_loop(__attribute__((unused)) void *dummy)
709709
{
710-
int ret;
711710
unsigned nb_ports;
712711
int i, j, nb_rx;
713712
unsigned lcore_id;
@@ -802,38 +801,8 @@ static int ans_main_loop(__attribute__((unused)) void *dummy)
802801
if (nb_rx == 0)
803802
continue;
804803

805-
/* Prefetch first packets */
806-
for (j = 0; j < PREFETCH_OFFSET && j < nb_rx; j++)
807-
{
808-
rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[j], void *));
809-
}
810-
811-
/* Prefetch and forward already prefetched packets */
812-
for (j = 0; j < (nb_rx - PREFETCH_OFFSET); j++)
813-
{
814-
rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[j + PREFETCH_OFFSET], void *));
815-
816-
/* add by ans_team ---start */
817-
818-
ret = ans_packet_handle(pkts_burst[j], portid);
819-
if(ret == ANS_MBUF_CONTINUE)
820-
ans_to_linux(portid, pkts_burst[j]);
821-
822-
/* add by ans_team ---end */
823-
}
824-
825-
/* Forward remaining prefetched packets */
826-
for (; j < nb_rx; j++)
827-
{
828-
829-
/* add by ans_team ---start */
830-
831-
ret = ans_packet_handle(pkts_burst[j], portid);
832-
if(ret == ANS_MBUF_CONTINUE)
833-
ans_to_linux(portid, pkts_burst[j]);
834-
835-
/* add by ans_team ---end */
836-
}
804+
ans_eth_rx_burst(portid, pkts_burst, nb_rx);
805+
837806
}
838807

839808
/* to support KNI, at 2014-12-15 */
@@ -935,20 +904,21 @@ int main(int argc, char **argv)
935904
printf("\ncore mask: %x, sockets number:%d, lcore number:%d \n", ans_user_conf.lcore_mask, ans_user_conf.socket_nb, ans_user_conf.lcore_nb);
936905

937906
printf("start to init ans \n");
938-
init_conf.max_sock_conn = ans_user_conf.lcore_nb * 128 * 1024;
907+
init_conf.sock_nb = ans_user_conf.lcore_nb * 128 * 1024;
939908

940909
init_conf.lcore_mask = ans_user_conf.lcore_mask;
941910
for(i = 0 ; i < MAX_NB_SOCKETS; i++)
942911
{
943912
init_conf.pktmbuf_pool[i] = ans_pktmbuf_pool[i];
944913
}
945914

915+
init_conf.port_send = ans_send_packet;
916+
init_conf.port_bypass = ans_bypass_packet;
917+
946918
ret = ans_initialize(&init_conf);
947919
if (ret != 0)
948920
rte_exit(EXIT_FAILURE, "Init ans failed \n");
949921

950-
951-
ans_register(ans_send_single_packet);
952922
/* add by ans_team ---end */
953923

954924
/* add by ans_team for testing ---start */

librte_ans/include/ans_errno.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,5 +411,7 @@
411411
#define ANS_FALSE 0
412412
#define ANS_TRUE 1
413413

414+
#define ANS_PKT_DONE 0
415+
#define ANS_PKT_CONTINUE 1
414416

415417
#endif

librte_ans/include/ans_init.h

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,18 @@
5050
*/
5151
struct ans_init_config
5252
{
53-
uint64_t lcore_mask; /**< lcore which used to run ans */
54-
uint32_t max_sock_conn; /**< support max sock connection */
55-
cpu_set_t cpu_set; /**< system default cpu set */
53+
uint64_t lcore_mask; /**< lcore which used to run ans */
54+
uint32_t sock_nb; /**< support max sock connection number */
55+
cpu_set_t cpu_set; /**< system default cpu set */
5656
struct rte_mempool *pktmbuf_pool[ANS_MAX_NB_SOCKETS]; /**< mbuf pools for each sockets */
57-
} __rte_cache_aligned;
5857

58+
int (*port_send)(uint8_t port, struct rte_mbuf *m); /** callback for sending one mbuf to port */
59+
60+
int (*port_bypass)(uint8_t port, struct rte_mbuf *m); /** callback for bypassing one mbuf to linux */
61+
62+
63+
} __rte_cache_aligned;
5964

60-
typedef int (*ans_send_packet_cb)(struct rte_mbuf *m, uint8_t port);
6165

6266
/**
6367
* Init ans stack.
@@ -69,31 +73,24 @@ typedef int (*ans_send_packet_cb)(struct rte_mbuf *m, uint8_t port);
6973
*/
7074
int ans_initialize(struct ans_init_config *user_conf);
7175

72-
/**
73-
* Register packet send callback to ans stack.
74-
* @param send_cb
75-
* callback function.
76-
*
77-
* @return 0 - SUCCESS, non-zero - FAILURE
78-
*
79-
*/
80-
int ans_register(ans_send_packet_cb send_cb);
81-
8276
/**
8377
* Handle the received packets by ans stack
8478
*
85-
* @param m
86-
* packet buffer.
8779
* @param portid
8880
* port id.
81+
* @param rx_pkts
82+
* packet buffer array.
83+
* @param nb_pkts
84+
* packets number.
8985
*
90-
* @return 0 - SUCCESS, non-zero - FAILURE
86+
* @return void
9187
*
9288
*/
93-
int ans_packet_handle(struct rte_mbuf *m, uint8_t portid);
89+
void ans_eth_rx_burst(uint8_t portid, struct rte_mbuf **rx_pkts, const uint16_t nb_pkts);
90+
9491

9592
/**
96-
* Handle the received packets by ans stack
93+
* Statistics dropped packets by port
9794
*
9895
* @param portid
9996
* port id.
@@ -103,7 +100,7 @@ int ans_register(ans_send_packet_cb send_cb);
103100
* @return
104101
*
105102
*/
106-
void ans_packet_stats(uint8_t portid, uint16_t packets_nb);
103+
void ans_eth_stats(uint8_t portid, uint16_t packets_nb);
107104

108105
/**
109106
* Handle ans internal message.

librte_ans/include/ans_ip_intf.h

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

74-
/* mbuf handle action */
75-
#define ANS_MBUF_DONE 0 /**< mbuf is handled by ans */
76-
#define ANS_MBUF_CONTINUE 1 /**< mbuf isn't handled by ans */
77-
7874

7975
/**
8076
* Add an interface.

librte_ans/librte_ans_broadwell.a

10.2 KB
Binary file not shown.

librte_ans/librte_ans_core2.a

9.99 KB
Binary file not shown.

librte_ans/librte_ans_haswell.a

10.2 KB
Binary file not shown.

librte_ans/librte_ans_ivybridge.a

9.99 KB
Binary file not shown.

librte_ans/librte_ans_sandybridge.a

9.99 KB
Binary file not shown.

librte_ans/librte_ans_westmere.a

9.99 KB
Binary file not shown.

0 commit comments

Comments
 (0)