DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] examples/l3fwd: pass flow arguments when starting l3fwd
@ 2017-09-28  2:31 Xiaoyun Li
  2017-09-30  1:59 ` [dpdk-dev] [PATCH v2] examples/l3fwd: pass flow arguments when start app Xiaoyun Li
  0 siblings, 1 reply; 8+ messages in thread
From: Xiaoyun Li @ 2017-09-28  2:31 UTC (permalink / raw)
  To: jingjing.wu; +Cc: dev, Xiaoyun Li

When the number of free descriptors goes below the LRXQTRESH, an immediate
interrupt is triggered. And lots of interrupts cause performance drop. This
patch enables to pass flow arguments when starting l3fwd example.

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
---
 examples/l3fwd/main.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 189 insertions(+), 2 deletions(-)

diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 81995fd..1a265a8 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -83,6 +83,7 @@
  */
 #define RTE_TEST_RX_DESC_DEFAULT 128
 #define RTE_TEST_TX_DESC_DEFAULT 512
+#define RTE_PMD_PARAM_UNSET -1
 
 #define MAX_TX_QUEUE_PER_PORT RTE_MAX_ETHPORTS
 #define MAX_RX_QUEUE_PER_PORT 128
@@ -92,6 +93,9 @@
 /* Static global variables used within this file. */
 static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
 static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
+static int16_t rx_free_thresh = RTE_PMD_PARAM_UNSET;
+static int16_t tx_free_thresh = RTE_PMD_PARAM_UNSET;
+static int16_t tx_rs_thresh = RTE_PMD_PARAM_UNSET;
 
 /**< Ports set in promiscuous mode off by default. */
 static int promiscuous_on;
@@ -320,7 +324,12 @@ print_usage(const char *prgname)
 		" [--no-numa]"
 		" [--hash-entry-num]"
 		" [--ipv6]"
-		" [--parse-ptype]\n\n"
+		" [--parse-ptype]"
+		" [--nb-rxd]"
+		" [--nb-txd]"
+		" [--rx-free-thresh]"
+		" [--tx-free-thresh]"
+		" [--tx-rs-thresh]\n\n"
 
 		"  -p PORTMASK: Hexadecimal bitmask of ports to configure\n"
 		"  -P : Enable promiscuous mode\n"
@@ -334,7 +343,12 @@ print_usage(const char *prgname)
 		"  --no-numa: Disable numa awareness\n"
 		"  --hash-entry-num: Specify the hash entry number in hexadecimal to be setup\n"
 		"  --ipv6: Set if running ipv6 packets\n"
-		"  --parse-ptype: Set to use software to analyze packet type\n\n",
+		"  --parse-ptype: Set to use software to analyze packet type\n\n"
+		"  --nb-rxd: Set number of descriptors of Rx queue\n"
+		"  --nb-txd: Set number of descriptors of Tx queue\n"
+		"  --rx-free-thresh: Set value of Tx free threshold\n"
+		"  --tx-free-thresh: Set value of Rx free threshold\n"
+		"  --tx-rs-thresh: Set value of Tx RS bit threshold\n\n",
 		prgname);
 }
 
@@ -389,6 +403,91 @@ parse_hash_entry_number(const char *hash_entry_num)
 }
 
 static int
+parse_nb_rxd(const char *nb_rxd_c)
+{
+	char *end = NULL;
+	unsigned int nb_rxd_t;
+
+	/* parse hexadecimal string */
+	nb_rxd_t = strtoul(nb_rxd_c, &end, 10);
+	if ((nb_rxd_c[0] == '\0') || (end == NULL) || (*end != '\0'))
+		return -1;
+
+	if (nb_rxd_t == 0)
+		return -1;
+
+	return nb_rxd_t;
+}
+
+static int
+parse_nb_txd(const char *nb_txd_c)
+{
+	char *end = NULL;
+	unsigned int nb_txd_t;
+
+	/* parse hexadecimal string */
+	nb_txd_t = strtoul(nb_txd_c, &end, 10);
+	if ((nb_txd_c[0] == '\0') || (end == NULL) || (*end != '\0'))
+		return -1;
+
+	if (nb_txd_t == 0)
+		return -1;
+
+	return nb_txd_t;
+}
+
+static int
+parse_rx_free_thresh(const char *rx_free_thresh_c)
+{
+	char *end = NULL;
+	unsigned int rx_free_thresh_t;
+
+	/* parse hexadecimal string */
+	rx_free_thresh_t = strtoul(rx_free_thresh_c, &end, 10);
+	if ((rx_free_thresh_c[0] == '\0') || (end == NULL) || (*end != '\0'))
+		return -1;
+
+	if (rx_free_thresh_t == 0)
+		return -1;
+
+	return rx_free_thresh_t;
+}
+
+static int
+parse_tx_free_thresh(const char *tx_free_thresh_c)
+{
+	char *end = NULL;
+	unsigned int tx_free_thresh_t;
+
+	/* parse hexadecimal string */
+	tx_free_thresh_t = strtoul(tx_free_thresh_c, &end, 16);
+	if ((tx_free_thresh_c[0] == '\0') || (end == NULL) || (*end != '\0'))
+		return -1;
+
+	if (tx_free_thresh_t == 0)
+		return -1;
+
+	return tx_free_thresh_t;
+}
+
+static int
+parse_tx_rs_thresh(const char *tx_rs_thresh_c)
+{
+	char *end = NULL;
+	unsigned int tx_rs_thresh_t;
+
+	/* parse hexadecimal string */
+	tx_rs_thresh_t = strtoul(tx_rs_thresh_c, &end, 10);
+	if ((tx_rs_thresh_c[0] == '\0') || (end == NULL) || (*end != '\0'))
+		return -1;
+
+	if (tx_rs_thresh_t == 0)
+		return -1;
+
+	return tx_rs_thresh_t;
+}
+
+static int
 parse_config(const char *q_arg)
 {
 	char s[256];
@@ -487,6 +586,11 @@ static const char short_options[] =
 #define CMD_LINE_OPT_ENABLE_JUMBO "enable-jumbo"
 #define CMD_LINE_OPT_HASH_ENTRY_NUM "hash-entry-num"
 #define CMD_LINE_OPT_PARSE_PTYPE "parse-ptype"
+#define CMD_LINE_OPT_NB_RXD "nb-rxd"
+#define CMD_LINE_OPT_NB_TXD "nb-txd"
+#define CMD_LINE_OPT_RX_FREE_THRESH "rx-free-thresh"
+#define CMD_LINE_OPT_TX_FREE_THRESH "tx-free-thresh"
+#define CMD_LINE_OPT_TX_RS_THRESH "tx-rs-thresh"
 enum {
 	/* long options mapped to a short option */
 
@@ -500,6 +604,11 @@ enum {
 	CMD_LINE_OPT_ENABLE_JUMBO_NUM,
 	CMD_LINE_OPT_HASH_ENTRY_NUM_NUM,
 	CMD_LINE_OPT_PARSE_PTYPE_NUM,
+	CMD_LINE_OPT_NB_RXD_NUM,
+	CMD_LINE_OPT_NB_TXD_NUM,
+	CMD_LINE_OPT_RX_FREE_THRESH_NUM,
+	CMD_LINE_OPT_TX_FREE_THRESH_NUM,
+	CMD_LINE_OPT_TX_RS_THRESH_NUM,
 };
 
 static const struct option lgopts[] = {
@@ -510,6 +619,11 @@ static const struct option lgopts[] = {
 	{CMD_LINE_OPT_ENABLE_JUMBO, 0, 0, CMD_LINE_OPT_ENABLE_JUMBO_NUM},
 	{CMD_LINE_OPT_HASH_ENTRY_NUM, 1, 0, CMD_LINE_OPT_HASH_ENTRY_NUM_NUM},
 	{CMD_LINE_OPT_PARSE_PTYPE, 0, 0, CMD_LINE_OPT_PARSE_PTYPE_NUM},
+	{CMD_LINE_OPT_NB_RXD, 1, 0, CMD_LINE_OPT_NB_RXD_NUM},
+	{CMD_LINE_OPT_NB_TXD, 1, 0, CMD_LINE_OPT_NB_TXD_NUM},
+	{CMD_LINE_OPT_RX_FREE_THRESH, 1, 0, CMD_LINE_OPT_RX_FREE_THRESH_NUM},
+	{CMD_LINE_OPT_TX_FREE_THRESH, 1, 0, CMD_LINE_OPT_TX_FREE_THRESH_NUM},
+	{CMD_LINE_OPT_TX_RS_THRESH, 1, 0, CMD_LINE_OPT_TX_RS_THRESH_NUM},
 	{NULL, 0, 0, 0}
 };
 
@@ -554,6 +668,11 @@ parse_args(int argc, char **argv)
 	const char *str12 =
 		"L3FWD: LPM and EM are mutually exclusive, select only one";
 	const char *str13 = "L3FWD: LPM or EM none selected, default LPM on";
+	const char *str14 = "L3FWD: Invalid Rx descriptors number";
+	const char *str15 = "L3FWD: Invalid Tx descriptors number";
+	const char *str16 = "L3FWD: Invalid Rx free threshold value";
+	const char *str17 = "L3FWD: Invalid Tx free threshold value";
+	const char *str18 = "L3FWD: Invalid Tx RS bit threshold value";
 
 	while ((opt = getopt_long(argc, argvopt, short_options,
 				lgopts, &option_index)) != EOF) {
@@ -652,6 +771,61 @@ parse_args(int argc, char **argv)
 			parse_ptype = 1;
 			break;
 
+		case CMD_LINE_OPT_NB_RXD_NUM:
+			ret = parse_nb_rxd(optarg);
+			if (ret > 0)
+				nb_rxd = ret;
+			else{
+				printf("%s\n", str14);
+				print_usage(prgname);
+				return -1;
+			}
+			break;
+
+		case CMD_LINE_OPT_NB_TXD_NUM:
+			ret = parse_nb_txd(optarg);
+			if (ret > 0)
+				nb_txd = ret;
+			else{
+				printf("%s\n", str15);
+				print_usage(prgname);
+				return -1;
+			}
+			break;
+
+		case CMD_LINE_OPT_RX_FREE_THRESH_NUM:
+			ret = parse_rx_free_thresh(optarg);
+			if (ret > 0)
+				rx_free_thresh = ret;
+			else{
+				printf("%s\n", str16);
+				print_usage(prgname);
+				return -1;
+			}
+			break;
+
+		case CMD_LINE_OPT_TX_FREE_THRESH_NUM:
+			ret = parse_tx_free_thresh(optarg);
+			if (ret > 0)
+				tx_free_thresh = ret;
+			else{
+				printf("%s\n", str17);
+				print_usage(prgname);
+				return -1;
+			}
+			break;
+
+		case CMD_LINE_OPT_TX_RS_THRESH_NUM:
+			ret = parse_tx_rs_thresh(optarg);
+			if (ret > 0)
+				tx_rs_thresh = ret;
+			else{
+				printf("%s\n", str18);
+				print_usage(prgname);
+				return -1;
+			}
+			break;
+
 		default:
 			print_usage(prgname);
 			return -1;
@@ -894,6 +1068,19 @@ main(int argc, char **argv)
 
 	/* initialize all ports */
 	for (portid = 0; portid < nb_ports; portid++) {
+		rte_eth_dev_info_get(portid, &dev_info);
+
+		if (rx_free_thresh != RTE_PMD_PARAM_UNSET)
+			dev_info.default_rxconf.rx_free_thresh = rx_free_thresh;
+
+		if (tx_free_thresh != RTE_PMD_PARAM_UNSET)
+			dev_info.default_txconf.tx_free_thresh = tx_free_thresh;
+
+		if (tx_rs_thresh != RTE_PMD_PARAM_UNSET)
+			dev_info.default_txconf.tx_rs_thresh = tx_rs_thresh;
+	}
+
+	for (portid = 0; portid < nb_ports; portid++) {
 		/* skip ports that are not enabled */
 		if ((enabled_port_mask & (1 << portid)) == 0) {
 			printf("\nSkipping disabled port %d\n", portid);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-10-24 21:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-28  2:31 [dpdk-dev] [PATCH] examples/l3fwd: pass flow arguments when starting l3fwd Xiaoyun Li
2017-09-30  1:59 ` [dpdk-dev] [PATCH v2] examples/l3fwd: pass flow arguments when start app Xiaoyun Li
2017-10-01 17:24   ` Stephen Hemminger
2017-10-05  8:35     ` Wu, Jingjing
2017-10-10  7:57       ` Wu, Jingjing
2017-10-18  7:11   ` [dpdk-dev] [PATCH v3] " Xiaoyun Li
2017-10-24  1:38     ` Wu, Jingjing
2017-10-24 21:44       ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).