Skip to content

Commit 429810e

Browse files
committed
routing forwarding performance reach 11.2mpps
1 parent 7e1ee13 commit 429810e

16 files changed

+53
-58
lines changed

ans/ans_main.c

Lines changed: 38 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ static int ans_init_lcore_rx_queues(struct ans_user_config *user_conf, struct a
289289
}
290290
else
291291
{
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;
294294
lcore_conf[lcore].n_rx_queue++;
295295
}
296296
}
@@ -474,7 +474,7 @@ static int ans_init_ports(unsigned short nb_ports, struct ans_user_config *user
474474
if (ret < 0)
475475
rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: err=%d, " "port=%d\n", ret, portid);
476476

477-
lcore_conf[lcore_id].tx_queue_id[portid] = queueid;
477+
lcore_conf[lcore_id].tx_queue[portid].queue_id = queueid;
478478

479479
queueid++;
480480
}
@@ -503,8 +503,8 @@ static int ans_init_ports(unsigned short nb_ports, struct ans_user_config *user
503503
/* init RX queues */
504504
for(queue = 0; queue < lcore_conf[lcore_id].n_rx_queue; ++queue)
505505
{
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;
508508

509509
if (user_conf->numa_on)
510510
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
590590
*@return values:
591591
*
592592
**********************************************************************/
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)
594594
{
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;
601596

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))
604599
{
605-
ans_eth_stats(port, n - ret);
606-
600+
left_nb = send_nb;
607601
do
608602
{
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);
611605
}
606+
607+
ans_eth_stats(port_id, nb_pkts, nb_pkts - send_nb);
612608

613609
return 0;
614610
}
@@ -626,25 +622,22 @@ static inline int ans_send_burst(struct ans_lcore_queue *qconf, uint16_t n, uint
626622
**********************************************************************/
627623
static inline int ans_send_packet(uint8_t port, struct rte_mbuf *m)
628624
{
629-
uint32_t lcore_id;
630-
uint16_t len;
631625
struct ans_lcore_queue *qconf;
626+
struct ans_tx_queue *tx_queue;
627+
628+
qconf = &ans_lcore_conf[rte_lcore_id()];
632629

633-
lcore_id = rte_lcore_id();
630+
tx_queue = &qconf->tx_queue[port];
634631

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;
639633

640-
/* enough pkts to be sent */
641-
if (unlikely(len == MAX_TX_BURST))
634+
if(tx_queue->pkts_nb == MAX_TX_BURST)
642635
{
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;
645639
}
646640

647-
qconf->tx_mbufs[port].len = len;
648641
return 0;
649642
}
650643

@@ -715,7 +708,8 @@ static int ans_main_loop(__attribute__((unused)) void *dummy)
715708
struct ans_lcore_queue *qconf;
716709
uint64_t timer_prev_tsc = 0, timer_cur_tsc, timer_diff_tsc;
717710
struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
718-
711+
struct ans_tx_queue *tx_queue;
712+
struct ans_rx_queue *rx_queue;
719713
const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * BURST_TX_DRAIN_US;
720714

721715
prev_tsc = 0;
@@ -733,8 +727,8 @@ static int ans_main_loop(__attribute__((unused)) void *dummy)
733727

734728
for (i = 0; i < qconf->n_rx_queue; i++)
735729
{
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;
738732
RTE_LOG(INFO, USER8, " -- lcoreid=%u portid=%hhu rxqueueid=%hhu\n", lcore_id, portid, queueid);
739733
}
740734

@@ -743,22 +737,20 @@ static int ans_main_loop(__attribute__((unused)) void *dummy)
743737

744738
while (1)
745739
{
746-
747-
cur_tsc = rte_rdtsc();
748-
749740
/* add by ans_team ---start */
750741
ans_message_handle();
751742
/* add by ans_team ---end */
752743

753-
744+
cur_tsc = rte_rdtsc();
745+
timer_cur_tsc = cur_tsc;
746+
754747
/*
755748
* Call the timer handler on each core: as we don't
756749
* need a very precise timer, so only call
757750
* rte_timer_manage() every ~10ms (at 2Ghz). In a real
758751
* application, this will enhance performances as
759752
* reading the HPET timer is not efficient.
760753
*/
761-
timer_cur_tsc = rte_rdtsc();
762754
timer_diff_tsc = timer_cur_tsc - timer_prev_tsc;
763755
if (timer_diff_tsc > TIMER_RESOLUTION_CYCLES)
764756
{
@@ -779,12 +771,12 @@ static int ans_main_loop(__attribute__((unused)) void *dummy)
779771
*/
780772
for (portid = 0; portid < nb_ports; portid++)
781773
{
782-
if (qconf->tx_mbufs[portid].len == 0)
774+
tx_queue = &qconf->tx_queue[portid];
775+
if(tx_queue->pkts_nb == 0)
783776
continue;
784777

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;
788780
}
789781

790782
prev_tsc = cur_tsc;
@@ -795,14 +787,13 @@ static int ans_main_loop(__attribute__((unused)) void *dummy)
795787
*/
796788
for (i = 0; i < qconf->n_rx_queue; ++i)
797789
{
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);
801793
if (nb_rx == 0)
802794
continue;
803795

804-
ans_eth_rx_burst(portid, pkts_burst, nb_rx);
805-
796+
ans_eth_rx_burst(rx_queue->port_id, pkts_burst, nb_rx);
806797
}
807798

808799
/* to support KNI, at 2014-12-15 */

ans/ans_main.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#define TX_WTHRESH 0 /**< Default values of TX write-back threshold reg. */
5555

5656
#define MAX_PKT_BURST 32
57-
#define MAX_TX_BURST 16 /* set tx burst as 1 for lower packet latency */
57+
#define MAX_TX_BURST 16 /* set tx burst as 1 for lower packet latency, shall set to 32 ? */
5858
#define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
5959

6060
#define MAX_MBUF_NB (1024 * 16)
@@ -87,13 +87,14 @@ struct ans_lcore_params
8787
} __rte_cache_aligned;
8888

8989

90-
struct ans_mbuf_table
90+
struct ans_tx_queue
9191
{
92-
uint16_t len;
93-
struct rte_mbuf *m_table[MAX_PKT_BURST];
94-
};
92+
struct rte_mbuf *pkts[MAX_PKT_BURST];
93+
uint16_t pkts_nb;
94+
uint8_t queue_id;
95+
}__rte_cache_aligned;
9596

96-
struct ans_lcore_rx_queue
97+
struct ans_rx_queue
9798
{
9899
uint8_t port_id;
99100
uint8_t queue_id;
@@ -118,10 +119,11 @@ struct ans_user_config
118119

119120
struct ans_lcore_queue
120121
{
121-
uint16_t n_rx_queue;
122-
struct ans_lcore_rx_queue rx_queue_list[MAX_RX_QUEUE_PER_LCORE];
123-
uint16_t tx_queue_id[RTE_MAX_ETHPORTS];
124-
struct ans_mbuf_table tx_mbufs[RTE_MAX_ETHPORTS];
122+
uint16_t n_rx_queue;
123+
struct ans_rx_queue rx_queue[MAX_RX_QUEUE_PER_LCORE];
124+
125+
struct ans_tx_queue tx_queue[RTE_MAX_ETHPORTS];
126+
125127
} __rte_cache_aligned;
126128

127129
#define MAX_NB_SOCKETS 8

librte_ans/include/ans_errno.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,5 +414,7 @@
414414

415415
#define ANS_PKT_DONE 0
416416
#define ANS_PKT_CONTINUE 1
417+
#define ANS_PKT_FWD 2
418+
#define ANS_PKT_LOCAL 3
417419

418420
#endif

librte_ans/include/ans_init.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void ans_eth_rx_burst(uint8_t portid, struct rte_mbuf **rx_pkts, const uint16_t
101101
* @return
102102
*
103103
*/
104-
void ans_eth_stats(uint8_t portid, uint16_t packets_nb);
104+
void ans_eth_stats(uint8_t portid, uint16_t packets_nb, uint16_t droped_nb);
105105

106106
/**
107107
* Handle ans internal message.

librte_ans/librte_ans_broadwell.a

2.21 KB
Binary file not shown.

librte_ans/librte_ans_core2.a

2.21 KB
Binary file not shown.

librte_ans/librte_ans_haswell.a

2.21 KB
Binary file not shown.

librte_ans/librte_ans_ivybridge.a

2.21 KB
Binary file not shown.

librte_ans/librte_ans_sandybridge.a

2.21 KB
Binary file not shown.

librte_ans/librte_ans_westmere.a

2.21 KB
Binary file not shown.

0 commit comments

Comments
 (0)