From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from stargate3.asicdesigners.com (stargate.chelsio.com [67.207.115.98]) by dpdk.org (Postfix) with ESMTP id 08D048DB4 for ; Fri, 20 Nov 2015 11:26:46 +0100 (CET) Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate3.asicdesigners.com (8.13.8/8.13.8) with ESMTP id tAKAQhfk012440; Fri, 20 Nov 2015 02:26:44 -0800 From: Rahul Lakkireddy To: dev@dpdk.org Date: Fri, 20 Nov 2015 15:56:37 +0530 Message-Id: <1448015197-30094-1-git-send-email-rahul.lakkireddy@chelsio.com> X-Mailer: git-send-email 2.5.3 Cc: Felix Marti , Kumar Sanghvi , Nirranjan Kirubaharan Subject: [dpdk-dev] [PATCH] ethdev: add a missing sanity check for nb_tx_desc during txq setup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2015 10:26:47 -0000 Add a sanity check for number of tx descriptors requested during tx queue setup. Return -EINVAL if the number requested does not meet the tx descriptor requirements of the device. Fixes: 80a1deb4c77a ("ethdev: add API to retrieve queue information") Signed-off-by: Rahul Lakkireddy Signed-off-by: Kumar Sanghvi --- lib/librte_ether/rte_ethdev.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index b19ac9a..dfd6c0b 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1342,6 +1342,18 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id, rte_eth_dev_info_get(port_id, &dev_info); + if (nb_tx_desc > dev_info.tx_desc_lim.nb_max || + nb_tx_desc < dev_info.tx_desc_lim.nb_min || + nb_tx_desc % dev_info.tx_desc_lim.nb_align != 0) { + PMD_DEBUG_TRACE("Invalid value for nb_tx_desc(=%hu), " + "should be: <= %hu, = %hu, and a product of %hu\n", + nb_tx_desc, + dev_info.tx_desc_lim.nb_max, + dev_info.tx_desc_lim.nb_min, + dev_info.tx_desc_lim.nb_align); + return -EINVAL; + } + if (tx_conf == NULL) tx_conf = &dev_info.default_txconf; -- 2.5.3