From: Rahul Lakkireddy Date: Fri, 20 Nov 2015 10:26:37 +0000 (+0530) Subject: ethdev: add a missing sanity check for Tx queue setup X-Git-Tag: spdx-start~8013 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=386c993e95f1;p=dpdk.git ethdev: add a missing sanity check for Tx queue setup 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 Acked-by: Konstantin Ananyev --- diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index b19ac9a817..dfd6c0b49f 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;