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 11E5BA04C8; Sat, 19 Sep 2020 12:48:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 007B91D9E7; Sat, 19 Sep 2020 12:47:43 +0200 (CEST) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by dpdk.org (Postfix) with ESMTP id E0BB91D9E4 for ; Sat, 19 Sep 2020 12:47:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=Ry9bs1QYoXjeLTSW4m 3tk4aXyLgiTY+RvuS2tiymK5Y=; b=SIsCXUy1gAMlRkRgHT+5tKxNLLKXoKMOE8 wjpxqx9SXDdn/kYybYErb8rj2WAfpGjWaazuc9v99g7G6azmJ33O9N8FsohAyV9i yx3IwxLTybnZf6eIzcmoZcE76vX/MNlb+wW6YQ/lYvKO2CO23tfMnGj74XFqL19u ZRQQ9pFKI= Received: from localhost.localdomain (unknown [65.49.108.226]) by smtp9 (Coremail) with SMTP id DcCowAB3fIit4WVfEoCpHA--.12337S7; Sat, 19 Sep 2020 18:47:38 +0800 (CST) From: "Wei Hu (Xavier)" To: dev@dpdk.org Cc: xavier.huwei@huawei.com Date: Sat, 19 Sep 2020 18:47:07 +0800 Message-Id: <20200919104708.58451-6-xavier_huwei@163.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200919104708.58451-1-xavier_huwei@163.com> References: <20200818120254.72792-1-huwei013@chinasoftinc.com> <20200919104708.58451-1-xavier_huwei@163.com> X-CM-TRANSID: DcCowAB3fIit4WVfEoCpHA--.12337S7 X-Coremail-Antispam: 1Uf129KBjvJXoWxWrWxtr4UXF4kJw18urWrGrg_yoWrXFWDpF 45KayxA395Zr43Wr93Jw4rua1F9F4fWw4xWrZ3Jr1jvws8ZF4DGr1UKrn7XF95Jryqkr13 uwnIgana9F1DAFJanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j21vsUUUUU= X-Originating-IP: [65.49.108.226] X-CM-SenderInfo: 50dyxv5ubk34lhl6il2tof0z/1tbiDguko1XlxqS5bwAAsG Subject: [dpdk-dev] [PATCH v3 5/6] app/testpmd: fix valid desc id check 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" From: Chengchang Tang The number of desc is a per queue configuration. But in the check function, nb_txd & nb_rxd are used to check whether the desc_id is valid. nb_txd & nb_rxd are the global configuration of number of desc. If the queue configuration is changed by cmdline liks: "port config xx txq xx ring_size xxx", the real value will be changed. This patch use the real value to check whether the desc_id is valid. And if these are not configured by user. It will use the default value to check it, since the rte_eth_rx_queue_setup & rte_eth_tx_queue_setup will use a default value to confiure the queue if nb_rx_desc or nb_tx_desc is zero. Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Wei Hu (Xavier) --- app/test-pmd/config.c | 53 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 882de2d..b7851c7 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1891,22 +1891,55 @@ tx_queue_id_is_invalid(queueid_t txq_id) } static int -rx_desc_id_is_invalid(uint16_t rxdesc_id) +rx_desc_id_is_invalid(portid_t port_id, queueid_t rxq_id, uint16_t rxdesc_id) { - if (rxdesc_id < nb_rxd) + struct rte_port *port = &ports[port_id]; + uint16_t ring_size; + + /* + * When configure the rxq by rte_eth_rx_queue_setup with nb_rx_desc + * being 0, it will use a default value provided by PMDs to setup this + * rxq. If the default value is 0, it will use the + * RTE_ETH_DEV_FALLBACK_RX_RINGSIZE to setup this rxq. + */ + if (port->nb_rx_desc[rxq_id]) + ring_size = port->nb_rx_desc[rxq_id]; + else if (port->dev_info.default_rxportconf.ring_size) + ring_size = port->dev_info.default_rxportconf.ring_size; + else + ring_size = RTE_ETH_DEV_FALLBACK_RX_RINGSIZE; + + if (rxdesc_id < ring_size) return 0; - printf("Invalid RX descriptor %d (must be < nb_rxd=%d)\n", - rxdesc_id, nb_rxd); + printf("Invalid RX descriptor %d (must be < ring_size=%d)\n", + rxdesc_id, ring_size); return 1; } static int -tx_desc_id_is_invalid(uint16_t txdesc_id) +tx_desc_id_is_invalid(portid_t port_id, queueid_t txq_id, uint16_t txdesc_id) { - if (txdesc_id < nb_txd) + struct rte_port *port = &ports[port_id]; + uint16_t ring_size; + + /* + * When configure the txq by rte_eth_tx_queue_setup with nb_tx_desc + * being 0, it will use a default value provided by PMDs to setup this + * txq. If the default value is 0, it will use the + * RTE_ETH_DEV_FALLBACK_TX_RINGSIZE to setup this txq. + */ + if (port->nb_tx_desc[txq_id]) + ring_size = port->nb_tx_desc[txq_id]; + else if (port->dev_info.default_txportconf.ring_size) + ring_size = port->dev_info.default_txportconf.ring_size; + else + ring_size = RTE_ETH_DEV_FALLBACK_RX_RINGSIZE; + + if (txdesc_id < ring_size) return 0; - printf("Invalid TX descriptor %d (must be < nb_txd=%d)\n", - txdesc_id, nb_txd); + + printf("Invalid TX descriptor %d (must be < ring_size=%d)\n", + txdesc_id, ring_size); return 1; } @@ -2031,7 +2064,7 @@ rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id) return; if (rx_queue_id_is_invalid(rxq_id)) return; - if (rx_desc_id_is_invalid(rxd_id)) + if (rx_desc_id_is_invalid(port_id, rxq_id, rxd_id)) return; rx_mz = ring_dma_zone_lookup("rx_ring", port_id, rxq_id); if (rx_mz == NULL) @@ -2048,7 +2081,7 @@ tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id) return; if (tx_queue_id_is_invalid(txq_id)) return; - if (tx_desc_id_is_invalid(txd_id)) + if (tx_desc_id_is_invalid(port_id, txq_id, txd_id)) return; tx_mz = ring_dma_zone_lookup("tx_ring", port_id, txq_id); if (tx_mz == NULL) -- 2.9.5