@@ -32,10 +32,6 @@
#define VECTOR_SIZE_DEFAULT MAX_PKT_BURST
#define VECTOR_TMO_NS_DEFAULT 1E6 /* 1ms */
-/*
- * Try to avoid TX buffering if we have at least MAX_TX_BURST packets to send.
- */
-#define MAX_TX_BURST (MAX_PKT_BURST / 2)
#define NB_SOCKETS 8
@@ -116,7 +112,11 @@ extern struct acl_algorithms acl_alg[];
extern uint32_t max_pkt_len;
-extern uint32_t nb_pkt_per_burst;
+extern uint32_t rx_pkt_burst;
+/*
+ * Try to avoid TX buffering if we have at least tx_pkt_burst packets to send.
+ */
+extern uint32_t tx_pkt_burst;
extern uint32_t mb_mempool_cache_size;
/* Send burst of packets on an output interface */
@@ -152,8 +152,8 @@ send_single_packet(struct lcore_conf *qconf,
len++;
/* enough pkts to be sent */
- if (unlikely(len == MAX_PKT_BURST)) {
- send_burst(qconf, MAX_PKT_BURST, port);
+ if (unlikely(len == tx_pkt_burst)) {
+ send_burst(qconf, tx_pkt_burst, port);
len = 0;
}
@@ -1136,7 +1136,7 @@ acl_main_loop(__rte_unused void *dummy)
portid = qconf->rx_queue_list[i].port_id;
queueid = qconf->rx_queue_list[i].queue_id;
nb_rx = rte_eth_rx_burst(portid, queueid,
- pkts_burst, nb_pkt_per_burst);
+ pkts_burst, rx_pkt_burst);
if (nb_rx > 0) {
nb_drop = acl_process_pkts(pkts_burst, hops,
@@ -71,7 +71,7 @@ send_packetsx4(struct lcore_conf *qconf, uint16_t port, struct rte_mbuf *m[],
* If TX buffer for that queue is empty, and we have enough packets,
* then send them straightway.
*/
- if (num >= MAX_TX_BURST && len == 0) {
+ if (num >= tx_pkt_burst / 2 && len == 0) {
n = rte_eth_tx_burst(port, qconf->tx_queue_id[port], m, num);
if (unlikely(n < num)) {
do {
@@ -644,7 +644,7 @@ em_main_loop(__rte_unused void *dummy)
portid = qconf->rx_queue_list[i].port_id;
queueid = qconf->rx_queue_list[i].queue_id;
nb_rx = rte_eth_rx_burst(portid, queueid, pkts_burst,
- nb_pkt_per_burst);
+ rx_pkt_burst);
if (nb_rx == 0)
continue;
@@ -239,7 +239,7 @@ fib_main_loop(__rte_unused void *dummy)
portid = qconf->rx_queue_list[i].port_id;
queueid = qconf->rx_queue_list[i].queue_id;
nb_rx = rte_eth_rx_burst(portid, queueid, pkts_burst,
- nb_pkt_per_burst);
+ rx_pkt_burst);
if (nb_rx == 0)
continue;
@@ -205,7 +205,7 @@ lpm_main_loop(__rte_unused void *dummy)
portid = qconf->rx_queue_list[i].port_id;
queueid = qconf->rx_queue_list[i].queue_id;
nb_rx = rte_eth_rx_burst(portid, queueid, pkts_burst,
- nb_pkt_per_burst);
+ rx_pkt_burst);
if (nb_rx == 0)
continue;
@@ -57,7 +57,8 @@
static_assert(MEMPOOL_CACHE_SIZE >= MAX_PKT_BURST, "MAX_PKT_BURST should be at most MEMPOOL_CACHE_SIZE");
uint16_t nb_rxd = RX_DESC_DEFAULT;
uint16_t nb_txd = TX_DESC_DEFAULT;
-uint32_t nb_pkt_per_burst = DEFAULT_PKT_BURST;
+uint32_t rx_pkt_burst = DEFAULT_PKT_BURST;
+uint32_t tx_pkt_burst = DEFAULT_PKT_BURST;
uint32_t mb_mempool_cache_size = MEMPOOL_CACHE_SIZE;
/**< Ports set in promiscuous mode off by default. */
@@ -399,7 +400,8 @@ print_usage(const char *prgname)
" --config (port,queue,lcore)[,(port,queue,lcore)]"
" [--rx-queue-size NPKTS]"
" [--tx-queue-size NPKTS]"
- " [--burst NPKTS]"
+ " [--rx-burst NPKTS]"
+ " [--tx-burst NPKTS]"
" [--mbcache CACHESZ]"
" [--eth-dest=X,MM:MM:MM:MM:MM:MM]"
" [--max-pkt-len PKTLEN]"
@@ -426,8 +428,10 @@ print_usage(const char *prgname)
" Default: %d\n"
" --tx-queue-size NPKTS: Tx queue size in decimal\n"
" Default: %d\n"
- " --burst NPKTS: Burst size in decimal\n"
- " Default: %d\n"
+ " --rx-burst NPKTS: RX Burst size in decimal\n"
+ " Default: %d, Maximum: %d\n"
+ " --tx-burst NPKTS: TX Burst size in decimal\n"
+ " Default: %d, Maximum: %d\n"
" --mbcache CACHESZ: Mbuf cache size in decimal\n"
" Default: %d\n"
" --eth-dest=X,MM:MM:MM:MM:MM:MM: Ethernet destination for port X\n"
@@ -459,7 +463,10 @@ print_usage(const char *prgname)
" another is route entry at while line leads with character '%c'.\n"
" --rule_ipv6=FILE: Specify the ipv6 rules entries file.\n"
" --alg: ACL classify method to use, one of: %s.\n\n",
- prgname, RX_DESC_DEFAULT, TX_DESC_DEFAULT, DEFAULT_PKT_BURST, MEMPOOL_CACHE_SIZE,
+ prgname, RX_DESC_DEFAULT, TX_DESC_DEFAULT,
+ DEFAULT_PKT_BURST, MAX_PKT_BURST,
+ DEFAULT_PKT_BURST, MAX_PKT_BURST,
+ MEMPOOL_CACHE_SIZE,
ACL_LEAD_CHAR, ROUTE_LEAD_CHAR, alg);
}
@@ -693,47 +700,30 @@ parse_mbcache_size(const char *optarg)
RTE_MEMPOOL_CACHE_MAX_SIZE);
}
-static void
-parse_pkt_burst(const char *optarg)
+static int
+parse_pkt_burst(const char *optarg, bool is_rx)
{
- struct rte_eth_dev_info dev_info;
unsigned long pkt_burst;
- uint16_t burst_size;
char *end = NULL;
- int ret;
/* parse decimal string */
pkt_burst = strtoul(optarg, &end, 10);
- if ((optarg[0] == '\0') || (end == NULL) || (*end != '\0'))
- return;
-
- if (pkt_burst > MAX_PKT_BURST) {
- RTE_LOG(INFO, L3FWD, "User provided burst must be <= %d. Using default value %d\n",
- MAX_PKT_BURST, nb_pkt_per_burst);
- return;
- } else if (pkt_burst > 0) {
- nb_pkt_per_burst = (uint32_t)pkt_burst;
- return;
+ if ((optarg[0] == '\0') || (end == NULL) || (*end != '\0')) {
+ RTE_LOG(ERR, L3FWD, "Invalid %s-burst\n", is_rx ? "rx" : "tx");
+ return -1;
}
- /* If user gives a value of zero, query the PMD for its recommended Rx burst size. */
- ret = rte_eth_dev_info_get(0, &dev_info);
- if (ret != 0)
- return;
- burst_size = dev_info.default_rxportconf.burst_size;
- if (burst_size == 0) {
- RTE_LOG(INFO, L3FWD, "PMD does not recommend a burst size. Using default value %d. "
- "User provided value must be in [1, %d]\n",
- nb_pkt_per_burst, MAX_PKT_BURST);
- return;
- } else if (burst_size > MAX_PKT_BURST) {
- RTE_LOG(INFO, L3FWD, "PMD recommended burst size %d exceeds maximum value %d. "
- "Using default value %d\n",
- burst_size, MAX_PKT_BURST, nb_pkt_per_burst);
- return;
+ if (pkt_burst > MAX_PKT_BURST || pkt_burst == 0) {
+ RTE_LOG(ERR, L3FWD, "User-provided %s burst must be in (0, %d].\n",
+ is_rx ? "Rx" : "Tx", MAX_PKT_BURST);
+ return -1;
+ } else if (pkt_burst > 0) {
+ if (is_rx)
+ rx_pkt_burst = (uint16_t)pkt_burst;
+ else
+ tx_pkt_burst = (uint16_t)pkt_burst;
}
- nb_pkt_per_burst = burst_size;
- RTE_LOG(INFO, L3FWD, "Using PMD-provided burst value %d\n", burst_size);
+ return 0;
}
#define MAX_JUMBO_PKT_LEN 9600
@@ -767,7 +757,8 @@ static const char short_options[] =
#define CMD_LINE_OPT_RULE_IPV4 "rule_ipv4"
#define CMD_LINE_OPT_RULE_IPV6 "rule_ipv6"
#define CMD_LINE_OPT_ALG "alg"
-#define CMD_LINE_OPT_PKT_BURST "burst"
+#define CMD_LINE_OPT_PKT_RX_BURST "rx-burst"
+#define CMD_LINE_OPT_PKT_TX_BURST "tx-burst"
#define CMD_LINE_OPT_MB_CACHE_SIZE "mbcache"
enum {
@@ -798,7 +789,8 @@ enum {
CMD_LINE_OPT_ENABLE_VECTOR_NUM,
CMD_LINE_OPT_VECTOR_SIZE_NUM,
CMD_LINE_OPT_VECTOR_TMO_NS_NUM,
- CMD_LINE_OPT_PKT_BURST_NUM,
+ CMD_LINE_OPT_RX_PKT_BURST_NUM,
+ CMD_LINE_OPT_TX_PKT_BURST_NUM,
CMD_LINE_OPT_MB_CACHE_SIZE_NUM,
};
@@ -826,7 +818,8 @@ static const struct option lgopts[] = {
{CMD_LINE_OPT_RULE_IPV4, 1, 0, CMD_LINE_OPT_RULE_IPV4_NUM},
{CMD_LINE_OPT_RULE_IPV6, 1, 0, CMD_LINE_OPT_RULE_IPV6_NUM},
{CMD_LINE_OPT_ALG, 1, 0, CMD_LINE_OPT_ALG_NUM},
- {CMD_LINE_OPT_PKT_BURST, 1, 0, CMD_LINE_OPT_PKT_BURST_NUM},
+ {CMD_LINE_OPT_PKT_RX_BURST, 1, 0, CMD_LINE_OPT_RX_PKT_BURST_NUM},
+ {CMD_LINE_OPT_PKT_TX_BURST, 1, 0, CMD_LINE_OPT_TX_PKT_BURST_NUM},
{CMD_LINE_OPT_MB_CACHE_SIZE, 1, 0, CMD_LINE_OPT_MB_CACHE_SIZE_NUM},
{NULL, 0, 0, 0}
};
@@ -916,8 +909,20 @@ parse_args(int argc, char **argv)
parse_queue_size(optarg, &nb_txd, 0);
break;
- case CMD_LINE_OPT_PKT_BURST_NUM:
- parse_pkt_burst(optarg);
+ case CMD_LINE_OPT_TX_PKT_BURST_NUM:
+ ret = parse_pkt_burst(optarg, false);
+ if (ret) {
+ print_usage(prgname);
+ return -1;
+ }
+ break;
+
+ case CMD_LINE_OPT_RX_PKT_BURST_NUM:
+ ret = parse_pkt_burst(optarg, true);
+ if (ret) {
+ print_usage(prgname);
+ return -1;
+ }
break;
case CMD_LINE_OPT_MB_CACHE_SIZE_NUM: