From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 80690A0598; Sat, 18 Apr 2020 05:45:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C67671E54D; Sat, 18 Apr 2020 05:45:41 +0200 (CEST) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id 6CC921DDAC for ; Sat, 18 Apr 2020 05:45:40 +0200 (CEST) Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 704B39800102C4B7902F for ; Sat, 18 Apr 2020 11:45:37 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Sat, 18 Apr 2020 11:45:30 +0800 From: Lijun Ou To: , CC: , Date: Sat, 18 Apr 2020 11:44:38 +0800 Message-ID: <1587181478-40649-1-git-send-email-oulijun@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v2] app/testpmd: configure rxd and txd number correctly X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Signed-off-by: Huisong Li Signed-off-by: Wei Hu (Xavier) --- V1->V2 1. Remove the modification for changing the mbuf code. --- app/test-pmd/cmdline.c | 11 +--- app/test-pmd/testpmd.c | 171 +++++++++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/testpmd.h | 2 + 3 files changed, 176 insertions(+), 8 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..99bacdd 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. 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