From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B412B45B5C; Thu, 17 Oct 2024 11:37:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 30760402EF; Thu, 17 Oct 2024 11:37:49 +0200 (CEST) Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by mails.dpdk.org (Postfix) with ESMTP id EA21340279 for ; Thu, 17 Oct 2024 11:37:47 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4XTjS01rmhz1yn5f; Thu, 17 Oct 2024 17:37:52 +0800 (CST) Received: from kwepemm600004.china.huawei.com (unknown [7.193.23.242]) by mail.maildlp.com (Postfix) with ESMTPS id 326011A0188; Thu, 17 Oct 2024 17:37:46 +0800 (CST) Received: from [10.67.121.59] (10.67.121.59) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 17 Oct 2024 17:37:45 +0800 Message-ID: <0cf7ccb3-8e23-fa5a-34be-5fe59d47cf3e@huawei.com> Date: Thu, 17 Oct 2024 17:37:43 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH v2 1/2] examples/l3fwd: add option to set RX burst size To: Jie Hai , CC: , , References: <20241012084052.3485-1-haijie1@huawei.com> <20241017085816.29351-1-haijie1@huawei.com> <20241017085816.29351-2-haijie1@huawei.com> From: "lihuisong (C)" In-Reply-To: <20241017085816.29351-2-haijie1@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.121.59] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600004.china.huawei.com (7.193.23.242) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Acked-by: Huisong Li 在 2024/10/17 16:58, Jie Hai 写道: > Now the Rx burst size is fixed to MAX_PKT_BURST (32). This > parameter needs to be modified in some performance optimization > scenarios. So an option '--burst' is added to set the burst size > explicitly. The default value is DEFAULT_PKT_BURST (32) and maximum > value is MAX_PKT_BURST (512). > > Signed-off-by: Jie Hai > Acked-by: Chengwen Feng > --- > examples/l3fwd/l3fwd.h | 7 +++-- > examples/l3fwd/l3fwd_acl.c | 2 +- > examples/l3fwd/l3fwd_em.c | 2 +- > examples/l3fwd/l3fwd_fib.c | 2 +- > examples/l3fwd/l3fwd_lpm.c | 2 +- > examples/l3fwd/main.c | 60 ++++++++++++++++++++++++++++++++++++-- > 6 files changed, 67 insertions(+), 8 deletions(-) > > diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h > index 93ce652d02b7..618e0eaa3af1 100644 > --- a/examples/l3fwd/l3fwd.h > +++ b/examples/l3fwd/l3fwd.h > @@ -23,10 +23,11 @@ > #define RX_DESC_DEFAULT 1024 > #define TX_DESC_DEFAULT 1024 > > -#define MAX_PKT_BURST 32 > +#define DEFAULT_PKT_BURST 32 > +#define MAX_PKT_BURST 512 > #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */ > > -#define MEMPOOL_CACHE_SIZE 256 > +#define MEMPOOL_CACHE_SIZE RTE_MEMPOOL_CACHE_MAX_SIZE > #define MAX_RX_QUEUE_PER_LCORE 16 > > #define VECTOR_SIZE_DEFAULT MAX_PKT_BURST > @@ -115,6 +116,8 @@ extern struct acl_algorithms acl_alg[]; > > extern uint32_t max_pkt_len; > > +extern uint32_t nb_pkt_per_burst; > + > /* Send burst of packets on an output interface */ > static inline int > send_burst(struct lcore_conf *qconf, uint16_t n, uint16_t port) > diff --git a/examples/l3fwd/l3fwd_acl.c b/examples/l3fwd/l3fwd_acl.c > index b635011ef708..ccb9946837ed 100644 > --- a/examples/l3fwd/l3fwd_acl.c > +++ b/examples/l3fwd/l3fwd_acl.c > @@ -1119,7 +1119,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, MAX_PKT_BURST); > + pkts_burst, nb_pkt_per_burst); > > if (nb_rx > 0) { > acl_process_pkts(pkts_burst, hops, nb_rx, > diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c > index 31a7e05e39d0..da9c45e3a482 100644 > --- a/examples/l3fwd/l3fwd_em.c > +++ b/examples/l3fwd/l3fwd_em.c > @@ -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, > - MAX_PKT_BURST); > + nb_pkt_per_burst); > if (nb_rx == 0) > continue; > > diff --git a/examples/l3fwd/l3fwd_fib.c b/examples/l3fwd/l3fwd_fib.c > index f38b19af3f57..aa81b12fe7dc 100644 > --- a/examples/l3fwd/l3fwd_fib.c > +++ b/examples/l3fwd/l3fwd_fib.c > @@ -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, > - MAX_PKT_BURST); > + nb_pkt_per_burst); > if (nb_rx == 0) > continue; > > diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c > index e8fd95aae9ce..048c02491378 100644 > --- a/examples/l3fwd/l3fwd_lpm.c > +++ b/examples/l3fwd/l3fwd_lpm.c > @@ -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, > - MAX_PKT_BURST); > + nb_pkt_per_burst); > if (nb_rx == 0) > continue; > > diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c > index 01b763e5ba11..2feae5b311a2 100644 > --- a/examples/l3fwd/main.c > +++ b/examples/l3fwd/main.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -53,8 +54,10 @@ > > #define MAX_LCORE_PARAMS 1024 > > +static_assert(MEMPOOL_CACHE_SIZE >= MAX_PKT_BURST); > uint16_t nb_rxd = RX_DESC_DEFAULT; > uint16_t nb_txd = TX_DESC_DEFAULT; > +uint32_t nb_pkt_per_burst = DEFAULT_PKT_BURST; > > /**< Ports set in promiscuous mode off by default. */ > static int promiscuous_on; > @@ -395,6 +398,7 @@ print_usage(const char *prgname) > " --config (port,queue,lcore)[,(port,queue,lcore)]" > " [--rx-queue-size NPKTS]" > " [--tx-queue-size NPKTS]" > + " [--burst NPKTS]" > " [--eth-dest=X,MM:MM:MM:MM:MM:MM]" > " [--max-pkt-len PKTLEN]" > " [--no-numa]" > @@ -420,6 +424,8 @@ 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" > " --eth-dest=X,MM:MM:MM:MM:MM:MM: Ethernet destination for port X\n" > " --max-pkt-len PKTLEN: maximum packet length in decimal (64-9600)\n" > " --no-numa: Disable numa awareness\n" > @@ -449,7 +455,7 @@ 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, > + prgname, RX_DESC_DEFAULT, TX_DESC_DEFAULT, DEFAULT_PKT_BURST, > ACL_LEAD_CHAR, ROUTE_LEAD_CHAR, alg); > } > > @@ -667,6 +673,49 @@ parse_lookup(const char *optarg) > return 0; > } > > +static void > +parse_pkt_burst(const char *optarg) > +{ > + 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 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; > + } > + nb_pkt_per_burst = burst_size; > + RTE_LOG(INFO, L3FWD, "Using PMD-provided burst value %d\n", burst_size); > +} > + > #define MAX_JUMBO_PKT_LEN 9600 > > static const char short_options[] = > @@ -698,6 +747,7 @@ 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" > > enum { > /* long options mapped to a short option */ > @@ -726,7 +776,8 @@ enum { > CMD_LINE_OPT_LOOKUP_NUM, > CMD_LINE_OPT_ENABLE_VECTOR_NUM, > CMD_LINE_OPT_VECTOR_SIZE_NUM, > - CMD_LINE_OPT_VECTOR_TMO_NS_NUM > + CMD_LINE_OPT_VECTOR_TMO_NS_NUM, > + CMD_LINE_OPT_PKT_BURST_NUM > }; > > static const struct option lgopts[] = { > @@ -753,6 +804,7 @@ 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}, > {NULL, 0, 0, 0} > }; > > @@ -841,6 +893,10 @@ 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); > + break; > + > case CMD_LINE_OPT_ETH_DEST_NUM: > parse_eth_dest(optarg); > break;