From patchwork Fri Nov 20 10:26:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Lakkireddy X-Patchwork-Id: 9018 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 837E28DB5; Fri, 20 Nov 2015 11:26:49 +0100 (CET) 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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;