DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/testpmd: configure rxd and txd number correctly
@ 2020-04-17 10:59 Lijun Ou
  2020-04-18  0:42 ` Ferruh Yigit
  0 siblings, 1 reply; 6+ messages in thread
From: Lijun Ou @ 2020-04-17 10:59 UTC (permalink / raw)
  To: xiaolong.ye, qi.z.zhang; +Cc: dev, linuxarm

When users configure rxds and txds by used port config cmd based
on testpmd application, it will not be able to configure rxd and
txd according to the max capability range supported by the actual
NIC hardware. Due testpmd defects, it can only configure a fixed
range to 0 to 2048.
The final result is that an incorrect printing prompt appears and
cannot be applied using rxd && txd according to the actual
capabilities supported by the device.
In order to solve the above problems, we modify the testpmd. First
by calling the rte_eth_dev_info_get api to obtain the max and min
rx/tx capability supported by the hns3, and then use this range
to compare with the actual value by users configured and make
reasonable limitation.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
 app/test-pmd/cmdline.c |  11 +--
 app/test-pmd/testpmd.c | 187 ++++++++++++++++++++++++++++++++++++++++++++++++-
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 190 insertions(+), 10 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 982322c..eb76f1d 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1922,18 +1922,13 @@ cmd_config_rx_tx_parsed(void *parsed_result,
 		nb_txq = res->value;
 	}
 	else if (!strcmp(res->name, "rxd")) {
-		if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
-			printf("rxd %d invalid - must be > 0 && <= %d\n",
-					res->value, RTE_TEST_RX_DESC_MAX);
+		if (check_nb_rxd(res->value) != 0)
 			return;
-		}
 		nb_rxd = res->value;
 	} else if (!strcmp(res->name, "txd")) {
-		if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
-			printf("txd %d invalid - must be > 0 && <= %d\n",
-					res->value, RTE_TEST_TX_DESC_MAX);
+		if (check_nb_txd(res->value) != 0)
 			return;
-		}
+
 		nb_txd = res->value;
 	} else {
 		printf("Unknown parameter\n");
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 035836a..042b75a 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1156,6 +1156,177 @@ check_nb_txq(queueid_t txq)
 }
 
 /*
+ * Get the allowed maximum number of RXDs of every rx queue.
+ * *pid return the port id which has minimal value of
+ * max_rxd in all queues of all ports.
+ */
+static uint16_t
+get_allowed_max_nb_rxd(portid_t *pid)
+{
+	uint16_t allowed_max_rxd = UINT16_MAX;
+	portid_t pi;
+	struct rte_eth_dev_info dev_info;
+
+	RTE_ETH_FOREACH_DEV(pi) {
+		if (eth_dev_info_get_print_err(pi, &dev_info) != 0)
+			continue;
+
+		if (dev_info.rx_desc_lim.nb_max < allowed_max_rxd) {
+			allowed_max_rxd = dev_info.rx_desc_lim.nb_max;
+			*pid = pi;
+		}
+	}
+	return allowed_max_rxd;
+}
+
+/*
+ * Get the allowed minimal number of RXDs of every rx queue.
+ * *pid return the port id which has minimal value of
+ * min_rxd in all queues of all ports.
+ */
+static uint16_t
+get_allowed_min_nb_rxd(portid_t *pid)
+{
+	uint16_t allowed_min_rxd = 0;
+	portid_t pi;
+	struct rte_eth_dev_info dev_info;
+
+	RTE_ETH_FOREACH_DEV(pi) {
+		if (eth_dev_info_get_print_err(pi, &dev_info) != 0)
+			continue;
+
+		if (dev_info.rx_desc_lim.nb_min > allowed_min_rxd) {
+			allowed_min_rxd = dev_info.rx_desc_lim.nb_min;
+			*pid = pi;
+		}
+	}
+
+	return allowed_min_rxd;
+}
+
+/*
+ * Check input rxd is valid or not.
+ * If input rxd is not greater than any of maximum number
+ * of RXDs of every Rx queues and is not less than any of
+ * minimal number of RXDs of every Rx queues, it is valid.
+ * if valid, return 0, else return -1
+ */
+int
+check_nb_rxd(queueid_t rxd)
+{
+	uint16_t allowed_max_rxd;
+	uint16_t allowed_min_rxd;
+	portid_t pid = 0;
+
+	allowed_max_rxd = get_allowed_max_nb_rxd(&pid);
+	if (rxd > allowed_max_rxd) {
+		printf("Fail: input rxd (%u) can't be greater "
+		       "than max_rxds (%u) of port %u\n",
+		       rxd,
+		       allowed_max_rxd,
+		       pid);
+		return -1;
+	}
+
+	allowed_min_rxd = get_allowed_min_nb_rxd(&pid);
+	if (rxd < allowed_min_rxd) {
+		printf("Fail: input rxd (%u) can't be less "
+		       "than min_rxds (%u) of port %u\n",
+		       rxd,
+		       allowed_min_rxd,
+		       pid);
+		return -1;
+	}
+
+	return 0;
+}
+
+/*
+ * Get the allowed maximum number of TXDs of every rx queues.
+ * *pid return the port id which has minimal value of
+ * max_txd in every tx queue.
+ */
+static uint16_t
+get_allowed_max_nb_txd(portid_t *pid)
+{
+	uint16_t allowed_max_txd = UINT16_MAX;
+	portid_t pi;
+	struct rte_eth_dev_info dev_info;
+
+	RTE_ETH_FOREACH_DEV(pi) {
+		if (eth_dev_info_get_print_err(pi, &dev_info) != 0)
+			continue;
+
+		if (dev_info.tx_desc_lim.nb_max < allowed_max_txd) {
+			allowed_max_txd = dev_info.tx_desc_lim.nb_max;
+			*pid = pi;
+		}
+	}
+	return allowed_max_txd;
+}
+
+/*
+ * Get the allowed maximum number of TXDs of every tx queues.
+ * *pid return the port id which has minimal value of
+ * min_txd in every tx queue.
+ */
+static uint16_t
+get_allowed_min_nb_txd(portid_t *pid)
+{
+	uint16_t allowed_min_txd = 0;
+	portid_t pi;
+	struct rte_eth_dev_info dev_info;
+
+	RTE_ETH_FOREACH_DEV(pi) {
+		if (eth_dev_info_get_print_err(pi, &dev_info) != 0)
+			continue;
+
+		if (dev_info.tx_desc_lim.nb_min > allowed_min_txd) {
+			allowed_min_txd = dev_info.tx_desc_lim.nb_min;
+			*pid = pi;
+		}
+	}
+
+	return allowed_min_txd;
+}
+
+/*
+ * Check input txd is valid or not.
+ * If input txd is not greater than any of maximum number
+ * of TXDs of every Rx queues, it is valid.
+ * if valid, return 0, else return -1
+ */
+int
+check_nb_txd(queueid_t txd)
+{
+	uint16_t allowed_max_txd;
+	uint16_t allowed_min_txd;
+	portid_t pid = 0;
+
+	allowed_max_txd = get_allowed_max_nb_txd(&pid);
+	if (txd > allowed_max_txd) {
+		printf("Fail: input txd (%u) can't be greater "
+		       "than max_txds (%u) of port %u\n",
+		       txd,
+		       allowed_max_txd,
+		       pid);
+		return -1;
+	}
+
+	allowed_min_txd = get_allowed_min_nb_txd(&pid);
+	if (txd < allowed_min_txd) {
+		printf("Fail: input txd (%u) can't be less "
+		       "than min_txds (%u) of port %u\n",
+		       txd,
+		       allowed_min_txd,
+		       pid);
+		return -1;
+	}
+	return 0;
+}
+
+
+/*
  * Get the allowed maximum number of hairpin queues.
  * *pid return the port id which has minimal value of
  * max_hairpin_queues in all ports.
@@ -1212,6 +1383,8 @@ init_config(void)
 	lcoreid_t  lc_id;
 	uint8_t port_per_socket[RTE_MAX_NUMA_NODES];
 	struct rte_gro_param gro_param;
+	uint16_t allowed_max_rxd;
+	uint16_t allowed_max_txd;
 	uint32_t gso_types;
 	uint16_t data_size;
 	bool warning = 0;
@@ -1239,6 +1412,9 @@ init_config(void)
 		fwd_lcores[lc_id]->cpuid_idx = lc_id;
 	}
 
+	allowed_max_rxd = RTE_TEST_RX_DESC_MAX;
+	allowed_max_txd = RTE_TEST_RX_DESC_MAX;
+
 	RTE_ETH_FOREACH_DEV(pid) {
 		port = &ports[pid];
 		/* Apply default TxRx configuration for all ports */
@@ -1299,6 +1475,13 @@ init_config(void)
 				warning = 1;
 			}
 		}
+
+		/* Get the maximum number of txd and rxd per queue. */
+		if (port->dev_info.tx_desc_lim.nb_max > allowed_max_rxd)
+			allowed_max_txd = port->dev_info.tx_desc_lim.nb_max;
+
+		if (port->dev_info.rx_desc_lim.nb_max > allowed_max_txd)
+			allowed_max_rxd = port->dev_info.rx_desc_lim.nb_max;
 	}
 
 	if (warning)
@@ -1317,9 +1500,9 @@ init_config(void)
 	if (param_total_num_mbufs)
 		nb_mbuf_per_pool = param_total_num_mbufs;
 	else {
-		nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX +
+		nb_mbuf_per_pool = allowed_max_rxd +
 			(nb_lcores * mb_mempool_cache) +
-			RTE_TEST_TX_DESC_MAX + MAX_PKT_BURST;
+			allowed_max_txd + MAX_PKT_BURST;
 		nb_mbuf_per_pool *= RTE_MAX_ETHPORTS;
 	}
 
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 7a7c73f..7ff4c5d 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -878,6 +878,8 @@ queueid_t get_allowed_max_nb_rxq(portid_t *pid);
 int check_nb_rxq(queueid_t rxq);
 queueid_t get_allowed_max_nb_txq(portid_t *pid);
 int check_nb_txq(queueid_t txq);
+int check_nb_rxd(queueid_t rxd);
+int check_nb_txd(queueid_t txd);
 queueid_t get_allowed_max_nb_hairpinq(portid_t *pid);
 int check_nb_hairpinq(queueid_t hairpinq);
 
-- 
2.7.4


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

* Re: [dpdk-dev] [PATCH] app/testpmd: configure rxd and txd number correctly
  2020-04-17 10:59 [dpdk-dev] [PATCH] app/testpmd: configure rxd and txd number correctly Lijun Ou
@ 2020-04-18  0:42 ` Ferruh Yigit
  2020-04-18  2:30   ` oulijun
  0 siblings, 1 reply; 6+ messages in thread
From: Ferruh Yigit @ 2020-04-18  0:42 UTC (permalink / raw)
  To: Lijun Ou, xiaolong.ye, qi.z.zhang; +Cc: dev, linuxarm

On 4/17/2020 11:59 AM, Lijun Ou wrote:
> When users configure rxds and txds by used port config cmd based
> on testpmd application, it will not be able to configure rxd and
> txd according to the max capability range supported by the actual
> NIC hardware. Due testpmd defects, it can only configure a fixed
> range to 0 to 2048.
> The final result is that an incorrect printing prompt appears and
> cannot be applied using rxd && txd according to the actual
> capabilities supported by the device.
> In order to solve the above problems, we modify the testpmd. First
> by calling the rte_eth_dev_info_get api to obtain the max and min
> rx/tx capability supported by the hns3, and then use this range
> to compare with the actual value by users configured and make
> reasonable limitation.
> 
> Signed-off-by: Lijun Ou <oulijun@huawei.com>
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>

<...>

> @@ -1212,6 +1383,8 @@ init_config(void)
>  	lcoreid_t  lc_id;
>  	uint8_t port_per_socket[RTE_MAX_NUMA_NODES];
>  	struct rte_gro_param gro_param;
> +	uint16_t allowed_max_rxd;
> +	uint16_t allowed_max_txd;
>  	uint32_t gso_types;
>  	uint16_t data_size;
>  	bool warning = 0;
> @@ -1239,6 +1412,9 @@ init_config(void)
>  		fwd_lcores[lc_id]->cpuid_idx = lc_id;
>  	}
>  
> +	allowed_max_rxd = RTE_TEST_RX_DESC_MAX;
> +	allowed_max_txd = RTE_TEST_RX_DESC_MAX;
> +
>  	RTE_ETH_FOREACH_DEV(pid) {
>  		port = &ports[pid];
>  		/* Apply default TxRx configuration for all ports */
> @@ -1299,6 +1475,13 @@ init_config(void)
>  				warning = 1;
>  			}
>  		}
> +
> +		/* Get the maximum number of txd and rxd per queue. */
> +		if (port->dev_info.tx_desc_lim.nb_max > allowed_max_rxd)
> +			allowed_max_txd = port->dev_info.tx_desc_lim.nb_max;
> +
> +		if (port->dev_info.rx_desc_lim.nb_max > allowed_max_txd)
> +			allowed_max_rxd = port->dev_info.rx_desc_lim.nb_max;
>  	}
>  
>  	if (warning)
> @@ -1317,9 +1500,9 @@ init_config(void)
>  	if (param_total_num_mbufs)
>  		nb_mbuf_per_pool = param_total_num_mbufs;
>  	else {
> -		nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX +
> +		nb_mbuf_per_pool = allowed_max_rxd +
>  			(nb_lcores * mb_mempool_cache) +
> -			RTE_TEST_TX_DESC_MAX + MAX_PKT_BURST;
> +			allowed_max_txd + MAX_PKT_BURST;

Overall patch looks good, but with above change, for the PMDs that doesn't
explicitly set 'dev_info.tx_desc_lim.nb_max' gets the default value
'UINT16_MAX', like virtual PMDs, and this increases the memmory requirement a lot.

What do you think to keep "port config all rxd|txd <value>" the fix, but remove
above nb_mbuf change?

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

* Re: [dpdk-dev] [PATCH] app/testpmd: configure rxd and txd number correctly
  2020-04-18  0:42 ` Ferruh Yigit
@ 2020-04-18  2:30   ` oulijun
  2020-04-20 13:29     ` Ferruh Yigit
  0 siblings, 1 reply; 6+ messages in thread
From: oulijun @ 2020-04-18  2:30 UTC (permalink / raw)
  To: Ferruh Yigit, xiaolong.ye, qi.z.zhang; +Cc: dev, linuxarm



在 2020/4/18 8:42, Ferruh Yigit 写道:
> On 4/17/2020 11:59 AM, Lijun Ou wrote:
>> When users configure rxds and txds by used port config cmd based
>> on testpmd application, it will not be able to configure rxd and
>> txd according to the max capability range supported by the actual
>> NIC hardware. Due testpmd defects, it can only configure a fixed
>> range to 0 to 2048.
>> The final result is that an incorrect printing prompt appears and
>> cannot be applied using rxd && txd according to the actual
>> capabilities supported by the device.
>> In order to solve the above problems, we modify the testpmd. First
>> by calling the rte_eth_dev_info_get api to obtain the max and min
>> rx/tx capability supported by the hns3, and then use this range
>> to compare with the actual value by users configured and make
>> reasonable limitation.
>>
>> Signed-off-by: Lijun Ou <oulijun@huawei.com>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
> 
> <...>
> 
>> @@ -1212,6 +1383,8 @@ init_config(void)
>>   	lcoreid_t  lc_id;
>>   	uint8_t port_per_socket[RTE_MAX_NUMA_NODES];
>>   	struct rte_gro_param gro_param;
>> +	uint16_t allowed_max_rxd;
>> +	uint16_t allowed_max_txd;
>>   	uint32_t gso_types;
>>   	uint16_t data_size;
>>   	bool warning = 0;
>> @@ -1239,6 +1412,9 @@ init_config(void)
>>   		fwd_lcores[lc_id]->cpuid_idx = lc_id;
>>   	}
>>   
>> +	allowed_max_rxd = RTE_TEST_RX_DESC_MAX;
>> +	allowed_max_txd = RTE_TEST_RX_DESC_MAX;
>> +
>>   	RTE_ETH_FOREACH_DEV(pid) {
>>   		port = &ports[pid];
>>   		/* Apply default TxRx configuration for all ports */
>> @@ -1299,6 +1475,13 @@ init_config(void)
>>   				warning = 1;
>>   			}
>>   		}
>> +
>> +		/* Get the maximum number of txd and rxd per queue. */
>> +		if (port->dev_info.tx_desc_lim.nb_max > allowed_max_rxd)
>> +			allowed_max_txd = port->dev_info.tx_desc_lim.nb_max;
>> +
>> +		if (port->dev_info.rx_desc_lim.nb_max > allowed_max_txd)
>> +			allowed_max_rxd = port->dev_info.rx_desc_lim.nb_max;
>>   	}
>>   
>>   	if (warning)
>> @@ -1317,9 +1500,9 @@ init_config(void)
>>   	if (param_total_num_mbufs)
>>   		nb_mbuf_per_pool = param_total_num_mbufs;
>>   	else {
>> -		nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX +
>> +		nb_mbuf_per_pool = allowed_max_rxd +
>>   			(nb_lcores * mb_mempool_cache) +
>> -			RTE_TEST_TX_DESC_MAX + MAX_PKT_BURST;
>> +			allowed_max_txd + MAX_PKT_BURST;
> 
> Overall patch looks good, but with above change, for the PMDs that doesn't
> explicitly set 'dev_info.tx_desc_lim.nb_max' gets the default value
> 'UINT16_MAX', like virtual PMDs, and this increases the memmory requirement a lot.
> 
Hi,Ferruh
   Thanks. if some PMDs are not configured according to the 
specifications that are actually supported, does the PMDs driver require 
such a large mbuf by default.
> What do you think to keep "port config all rxd|txd <value>" the fix, but remove
> above nb_mbuf change?
Actually, I agree with your suggestion. But at the same time worry about 
whether mbuf is not enough, when rxd/txd is greater that 
RTE_TEST_TX_DESC_MAX

Thanks
Lijun Ou
> 
> .
> 


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

* Re: [dpdk-dev] [PATCH] app/testpmd: configure rxd and txd number correctly
  2020-04-18  2:30   ` oulijun
@ 2020-04-20 13:29     ` Ferruh Yigit
  2020-04-21  1:19       ` oulijun
  0 siblings, 1 reply; 6+ messages in thread
From: Ferruh Yigit @ 2020-04-20 13:29 UTC (permalink / raw)
  To: oulijun, xiaolong.ye, qi.z.zhang; +Cc: dev, linuxarm

On 4/18/2020 3:30 AM, oulijun wrote:
> 
> 
> 在 2020/4/18 8:42, Ferruh Yigit 写道:
>> On 4/17/2020 11:59 AM, Lijun Ou wrote:
>>> When users configure rxds and txds by used port config cmd based
>>> on testpmd application, it will not be able to configure rxd and
>>> txd according to the max capability range supported by the actual
>>> NIC hardware. Due testpmd defects, it can only configure a fixed
>>> range to 0 to 2048.
>>> The final result is that an incorrect printing prompt appears and
>>> cannot be applied using rxd && txd according to the actual
>>> capabilities supported by the device.
>>> In order to solve the above problems, we modify the testpmd. First
>>> by calling the rte_eth_dev_info_get api to obtain the max and min
>>> rx/tx capability supported by the hns3, and then use this range
>>> to compare with the actual value by users configured and make
>>> reasonable limitation.
>>>
>>> Signed-off-by: Lijun Ou <oulijun@huawei.com>
>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
>>
>> <...>
>>
>>> @@ -1212,6 +1383,8 @@ init_config(void)
>>>   	lcoreid_t  lc_id;
>>>   	uint8_t port_per_socket[RTE_MAX_NUMA_NODES];
>>>   	struct rte_gro_param gro_param;
>>> +	uint16_t allowed_max_rxd;
>>> +	uint16_t allowed_max_txd;
>>>   	uint32_t gso_types;
>>>   	uint16_t data_size;
>>>   	bool warning = 0;
>>> @@ -1239,6 +1412,9 @@ init_config(void)
>>>   		fwd_lcores[lc_id]->cpuid_idx = lc_id;
>>>   	}
>>>   
>>> +	allowed_max_rxd = RTE_TEST_RX_DESC_MAX;
>>> +	allowed_max_txd = RTE_TEST_RX_DESC_MAX;
>>> +
>>>   	RTE_ETH_FOREACH_DEV(pid) {
>>>   		port = &ports[pid];
>>>   		/* Apply default TxRx configuration for all ports */
>>> @@ -1299,6 +1475,13 @@ init_config(void)
>>>   				warning = 1;
>>>   			}
>>>   		}
>>> +
>>> +		/* Get the maximum number of txd and rxd per queue. */
>>> +		if (port->dev_info.tx_desc_lim.nb_max > allowed_max_rxd)
>>> +			allowed_max_txd = port->dev_info.tx_desc_lim.nb_max;
>>> +
>>> +		if (port->dev_info.rx_desc_lim.nb_max > allowed_max_txd)
>>> +			allowed_max_rxd = port->dev_info.rx_desc_lim.nb_max;
>>>   	}
>>>   
>>>   	if (warning)
>>> @@ -1317,9 +1500,9 @@ init_config(void)
>>>   	if (param_total_num_mbufs)
>>>   		nb_mbuf_per_pool = param_total_num_mbufs;
>>>   	else {
>>> -		nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX +
>>> +		nb_mbuf_per_pool = allowed_max_rxd +
>>>   			(nb_lcores * mb_mempool_cache) +
>>> -			RTE_TEST_TX_DESC_MAX + MAX_PKT_BURST;
>>> +			allowed_max_txd + MAX_PKT_BURST;
>>
>> Overall patch looks good, but with above change, for the PMDs that doesn't
>> explicitly set 'dev_info.tx_desc_lim.nb_max' gets the default value
>> 'UINT16_MAX', like virtual PMDs, and this increases the memmory requirement a lot.
>>
> Hi,Ferruh
>    Thanks. if some PMDs are not configured according to the 
> specifications that are actually supported, does the PMDs driver require 
> such a large mbuf by default.
>> What do you think to keep "port config all rxd|txd <value>" the fix, but remove
>> above nb_mbuf change?
> Actually, I agree with your suggestion. But at the same time worry about 
> whether mbuf is not enough, when rxd/txd is greater that 
> RTE_TEST_TX_DESC_MAX

That is valid concern I think, but user can override the number of mbufs with
"--total-num-mbufs" parameter, and if device has more than 2048 descriptor the
user can provide bigger numbers with this param.

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

* Re: [dpdk-dev] [PATCH] app/testpmd: configure rxd and txd number correctly
  2020-04-20 13:29     ` Ferruh Yigit
@ 2020-04-21  1:19       ` oulijun
  0 siblings, 0 replies; 6+ messages in thread
From: oulijun @ 2020-04-21  1:19 UTC (permalink / raw)
  To: Ferruh Yigit, xiaolong.ye, qi.z.zhang; +Cc: dev, linuxarm



在 2020/4/20 21:29, Ferruh Yigit 写道:
> On 4/18/2020 3:30 AM, oulijun wrote:
>>
>>
>> 在 2020/4/18 8:42, Ferruh Yigit 写道:
>>> On 4/17/2020 11:59 AM, Lijun Ou wrote:
>>>> When users configure rxds and txds by used port config cmd based
>>>> on testpmd application, it will not be able to configure rxd and
>>>> txd according to the max capability range supported by the actual
>>>> NIC hardware. Due testpmd defects, it can only configure a fixed
>>>> range to 0 to 2048.
>>>> The final result is that an incorrect printing prompt appears and
>>>> cannot be applied using rxd && txd according to the actual
>>>> capabilities supported by the device.
>>>> In order to solve the above problems, we modify the testpmd. First
>>>> by calling the rte_eth_dev_info_get api to obtain the max and min
>>>> rx/tx capability supported by the hns3, and then use this range
>>>> to compare with the actual value by users configured and make
>>>> reasonable limitation.
>>>>
>>>> Signed-off-by: Lijun Ou <oulijun@huawei.com>
>>>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>>>> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
>>>
>>> <...>
>>>
>>>> @@ -1212,6 +1383,8 @@ init_config(void)
>>>>    	lcoreid_t  lc_id;
>>>>    	uint8_t port_per_socket[RTE_MAX_NUMA_NODES];
>>>>    	struct rte_gro_param gro_param;
>>>> +	uint16_t allowed_max_rxd;
>>>> +	uint16_t allowed_max_txd;
>>>>    	uint32_t gso_types;
>>>>    	uint16_t data_size;
>>>>    	bool warning = 0;
>>>> @@ -1239,6 +1412,9 @@ init_config(void)
>>>>    		fwd_lcores[lc_id]->cpuid_idx = lc_id;
>>>>    	}
>>>>    
>>>> +	allowed_max_rxd = RTE_TEST_RX_DESC_MAX;
>>>> +	allowed_max_txd = RTE_TEST_RX_DESC_MAX;
>>>> +
>>>>    	RTE_ETH_FOREACH_DEV(pid) {
>>>>    		port = &ports[pid];
>>>>    		/* Apply default TxRx configuration for all ports */
>>>> @@ -1299,6 +1475,13 @@ init_config(void)
>>>>    				warning = 1;
>>>>    			}
>>>>    		}
>>>> +
>>>> +		/* Get the maximum number of txd and rxd per queue. */
>>>> +		if (port->dev_info.tx_desc_lim.nb_max > allowed_max_rxd)
>>>> +			allowed_max_txd = port->dev_info.tx_desc_lim.nb_max;
>>>> +
>>>> +		if (port->dev_info.rx_desc_lim.nb_max > allowed_max_txd)
>>>> +			allowed_max_rxd = port->dev_info.rx_desc_lim.nb_max;
>>>>    	}
>>>>    
>>>>    	if (warning)
>>>> @@ -1317,9 +1500,9 @@ init_config(void)
>>>>    	if (param_total_num_mbufs)
>>>>    		nb_mbuf_per_pool = param_total_num_mbufs;
>>>>    	else {
>>>> -		nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX +
>>>> +		nb_mbuf_per_pool = allowed_max_rxd +
>>>>    			(nb_lcores * mb_mempool_cache) +
>>>> -			RTE_TEST_TX_DESC_MAX + MAX_PKT_BURST;
>>>> +			allowed_max_txd + MAX_PKT_BURST;
>>>
>>> Overall patch looks good, but with above change, for the PMDs that doesn't
>>> explicitly set 'dev_info.tx_desc_lim.nb_max' gets the default value
>>> 'UINT16_MAX', like virtual PMDs, and this increases the memmory requirement a lot.
>>>
>> Hi,Ferruh
>>     Thanks. if some PMDs are not configured according to the
>> specifications that are actually supported, does the PMDs driver require
>> such a large mbuf by default.
>>> What do you think to keep "port config all rxd|txd <value>" the fix, but remove
>>> above nb_mbuf change?
>> Actually, I agree with your suggestion. But at the same time worry about
>> whether mbuf is not enough, when rxd/txd is greater that
>> RTE_TEST_TX_DESC_MAX
> 
> That is valid concern I think, but user can override the number of mbufs with
> "--total-num-mbufs" parameter, and if device has more than 2048 descriptor the
> user can provide bigger numbers with this param.
> 
Thanks. I see. I have sent the V2.
> .
> 


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

* [dpdk-dev] [PATCH] app/testpmd: configure rxd and txd number correctly
@ 2020-04-17  9:47 Lijun Ou
  0 siblings, 0 replies; 6+ messages in thread
From: Lijun Ou @ 2020-04-17  9:47 UTC (permalink / raw)
  To: xiaolong.ye, qi.z.zhang; +Cc: dev, linuxarm

When users configure rxds and txds by used port config cmd based
on testpmd application, it will not be able to configure rxd and
txd according to the max capability range supported by the actual
NIC hardware. Due testpmd defects, it can only configure a fixed
range to 0 to 2048.
The final result is that an incorrect printing prompt appears and
cannot be applied using rxd && txd according to the actual
capabilities supported by the device.
In order to solve the above problems, we modify the testpmd. First
by calling the rte_eth_dev_info_get api to obtain the max and min
rx/tx capability supported by the hns3, and then use this range
to compare with the actual value by users configured and make
reasonable limitation.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
 app/test-pmd/cmdline.c |  11 +--
 app/test-pmd/testpmd.c | 187 ++++++++++++++++++++++++++++++++++++++++++++++++-
 app/test-pmd/testpmd.h |   2 +
 3 files changed, 190 insertions(+), 10 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 982322c..eb76f1d 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1922,18 +1922,13 @@ cmd_config_rx_tx_parsed(void *parsed_result,
 		nb_txq = res->value;
 	}
 	else if (!strcmp(res->name, "rxd")) {
-		if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
-			printf("rxd %d invalid - must be > 0 && <= %d\n",
-					res->value, RTE_TEST_RX_DESC_MAX);
+		if (check_nb_rxd(res->value) != 0)
 			return;
-		}
 		nb_rxd = res->value;
 	} else if (!strcmp(res->name, "txd")) {
-		if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
-			printf("txd %d invalid - must be > 0 && <= %d\n",
-					res->value, RTE_TEST_TX_DESC_MAX);
+		if (check_nb_txd(res->value) != 0)
 			return;
-		}
+
 		nb_txd = res->value;
 	} else {
 		printf("Unknown parameter\n");
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 035836a..042b75a 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1156,6 +1156,177 @@ check_nb_txq(queueid_t txq)
 }
 
 /*
+ * Get the allowed maximum number of RXDs of every rx queue.
+ * *pid return the port id which has minimal value of
+ * max_rxd in all queues of all ports.
+ */
+static uint16_t
+get_allowed_max_nb_rxd(portid_t *pid)
+{
+	uint16_t allowed_max_rxd = UINT16_MAX;
+	portid_t pi;
+	struct rte_eth_dev_info dev_info;
+
+	RTE_ETH_FOREACH_DEV(pi) {
+		if (eth_dev_info_get_print_err(pi, &dev_info) != 0)
+			continue;
+
+		if (dev_info.rx_desc_lim.nb_max < allowed_max_rxd) {
+			allowed_max_rxd = dev_info.rx_desc_lim.nb_max;
+			*pid = pi;
+		}
+	}
+	return allowed_max_rxd;
+}
+
+/*
+ * Get the allowed minimal number of RXDs of every rx queue.
+ * *pid return the port id which has minimal value of
+ * min_rxd in all queues of all ports.
+ */
+static uint16_t
+get_allowed_min_nb_rxd(portid_t *pid)
+{
+	uint16_t allowed_min_rxd = 0;
+	portid_t pi;
+	struct rte_eth_dev_info dev_info;
+
+	RTE_ETH_FOREACH_DEV(pi) {
+		if (eth_dev_info_get_print_err(pi, &dev_info) != 0)
+			continue;
+
+		if (dev_info.rx_desc_lim.nb_min > allowed_min_rxd) {
+			allowed_min_rxd = dev_info.rx_desc_lim.nb_min;
+			*pid = pi;
+		}
+	}
+
+	return allowed_min_rxd;
+}
+
+/*
+ * Check input rxd is valid or not.
+ * If input rxd is not greater than any of maximum number
+ * of RXDs of every Rx queues and is not less than any of
+ * minimal number of RXDs of every Rx queues, it is valid.
+ * if valid, return 0, else return -1
+ */
+int
+check_nb_rxd(queueid_t rxd)
+{
+	uint16_t allowed_max_rxd;
+	uint16_t allowed_min_rxd;
+	portid_t pid = 0;
+
+	allowed_max_rxd = get_allowed_max_nb_rxd(&pid);
+	if (rxd > allowed_max_rxd) {
+		printf("Fail: input rxd (%u) can't be greater "
+		       "than max_rxds (%u) of port %u\n",
+		       rxd,
+		       allowed_max_rxd,
+		       pid);
+		return -1;
+	}
+
+	allowed_min_rxd = get_allowed_min_nb_rxd(&pid);
+	if (rxd < allowed_min_rxd) {
+		printf("Fail: input rxd (%u) can't be less "
+		       "than min_rxds (%u) of port %u\n",
+		       rxd,
+		       allowed_min_rxd,
+		       pid);
+		return -1;
+	}
+
+	return 0;
+}
+
+/*
+ * Get the allowed maximum number of TXDs of every rx queues.
+ * *pid return the port id which has minimal value of
+ * max_txd in every tx queue.
+ */
+static uint16_t
+get_allowed_max_nb_txd(portid_t *pid)
+{
+	uint16_t allowed_max_txd = UINT16_MAX;
+	portid_t pi;
+	struct rte_eth_dev_info dev_info;
+
+	RTE_ETH_FOREACH_DEV(pi) {
+		if (eth_dev_info_get_print_err(pi, &dev_info) != 0)
+			continue;
+
+		if (dev_info.tx_desc_lim.nb_max < allowed_max_txd) {
+			allowed_max_txd = dev_info.tx_desc_lim.nb_max;
+			*pid = pi;
+		}
+	}
+	return allowed_max_txd;
+}
+
+/*
+ * Get the allowed maximum number of TXDs of every tx queues.
+ * *pid return the port id which has minimal value of
+ * min_txd in every tx queue.
+ */
+static uint16_t
+get_allowed_min_nb_txd(portid_t *pid)
+{
+	uint16_t allowed_min_txd = 0;
+	portid_t pi;
+	struct rte_eth_dev_info dev_info;
+
+	RTE_ETH_FOREACH_DEV(pi) {
+		if (eth_dev_info_get_print_err(pi, &dev_info) != 0)
+			continue;
+
+		if (dev_info.tx_desc_lim.nb_min > allowed_min_txd) {
+			allowed_min_txd = dev_info.tx_desc_lim.nb_min;
+			*pid = pi;
+		}
+	}
+
+	return allowed_min_txd;
+}
+
+/*
+ * Check input txd is valid or not.
+ * If input txd is not greater than any of maximum number
+ * of TXDs of every Rx queues, it is valid.
+ * if valid, return 0, else return -1
+ */
+int
+check_nb_txd(queueid_t txd)
+{
+	uint16_t allowed_max_txd;
+	uint16_t allowed_min_txd;
+	portid_t pid = 0;
+
+	allowed_max_txd = get_allowed_max_nb_txd(&pid);
+	if (txd > allowed_max_txd) {
+		printf("Fail: input txd (%u) can't be greater "
+		       "than max_txds (%u) of port %u\n",
+		       txd,
+		       allowed_max_txd,
+		       pid);
+		return -1;
+	}
+
+	allowed_min_txd = get_allowed_min_nb_txd(&pid);
+	if (txd < allowed_min_txd) {
+		printf("Fail: input txd (%u) can't be less "
+		       "than min_txds (%u) of port %u\n",
+		       txd,
+		       allowed_min_txd,
+		       pid);
+		return -1;
+	}
+	return 0;
+}
+
+
+/*
  * Get the allowed maximum number of hairpin queues.
  * *pid return the port id which has minimal value of
  * max_hairpin_queues in all ports.
@@ -1212,6 +1383,8 @@ init_config(void)
 	lcoreid_t  lc_id;
 	uint8_t port_per_socket[RTE_MAX_NUMA_NODES];
 	struct rte_gro_param gro_param;
+	uint16_t allowed_max_rxd;
+	uint16_t allowed_max_txd;
 	uint32_t gso_types;
 	uint16_t data_size;
 	bool warning = 0;
@@ -1239,6 +1412,9 @@ init_config(void)
 		fwd_lcores[lc_id]->cpuid_idx = lc_id;
 	}
 
+	allowed_max_rxd = RTE_TEST_RX_DESC_MAX;
+	allowed_max_txd = RTE_TEST_RX_DESC_MAX;
+
 	RTE_ETH_FOREACH_DEV(pid) {
 		port = &ports[pid];
 		/* Apply default TxRx configuration for all ports */
@@ -1299,6 +1475,13 @@ init_config(void)
 				warning = 1;
 			}
 		}
+
+		/* Get the maximum number of txd and rxd per queue. */
+		if (port->dev_info.tx_desc_lim.nb_max > allowed_max_rxd)
+			allowed_max_txd = port->dev_info.tx_desc_lim.nb_max;
+
+		if (port->dev_info.rx_desc_lim.nb_max > allowed_max_txd)
+			allowed_max_rxd = port->dev_info.rx_desc_lim.nb_max;
 	}
 
 	if (warning)
@@ -1317,9 +1500,9 @@ init_config(void)
 	if (param_total_num_mbufs)
 		nb_mbuf_per_pool = param_total_num_mbufs;
 	else {
-		nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX +
+		nb_mbuf_per_pool = allowed_max_rxd +
 			(nb_lcores * mb_mempool_cache) +
-			RTE_TEST_TX_DESC_MAX + MAX_PKT_BURST;
+			allowed_max_txd + MAX_PKT_BURST;
 		nb_mbuf_per_pool *= RTE_MAX_ETHPORTS;
 	}
 
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 7a7c73f..7ff4c5d 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -878,6 +878,8 @@ queueid_t get_allowed_max_nb_rxq(portid_t *pid);
 int check_nb_rxq(queueid_t rxq);
 queueid_t get_allowed_max_nb_txq(portid_t *pid);
 int check_nb_txq(queueid_t txq);
+int check_nb_rxd(queueid_t rxd);
+int check_nb_txd(queueid_t txd);
 queueid_t get_allowed_max_nb_hairpinq(portid_t *pid);
 int check_nb_hairpinq(queueid_t hairpinq);
 
-- 
2.7.4


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

end of thread, other threads:[~2020-04-21  1:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-17 10:59 [dpdk-dev] [PATCH] app/testpmd: configure rxd and txd number correctly Lijun Ou
2020-04-18  0:42 ` Ferruh Yigit
2020-04-18  2:30   ` oulijun
2020-04-20 13:29     ` Ferruh Yigit
2020-04-21  1:19       ` oulijun
  -- strict thread matches above, loose matches on Subject: below --
2020-04-17  9:47 Lijun Ou

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).