From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by dpdk.org (Postfix) with ESMTP id AF558C468 for ; Fri, 24 Jul 2015 19:06:18 +0200 (CEST) Received: by pachj5 with SMTP id hj5so17136232pac.3 for ; Fri, 24 Jul 2015 10:06:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ATkwYzFzGVVE9AUsON/lc56Yu137aVj/KBWVMqYh6Zc=; b=HJJ+xCEtFf2w3jv3WUlwIX7ByEf6UFr4woP7L9r7Uotcy+mgQe3f+5TlpqtmqE1Ljp hOZdLv4Hobm6ORkFfUl0pH6QbPUPg8S6JYmja4bCAMrSCmrEHenQpY2HTKgLnknAvaBy UPynSiCn/ghoQiRgzWwXhIv6h8reI7QQnbVFThi9XKLEJZFK0uO0Ev/hNK/8qrlUyWY0 kQy3lP19wcpS3Odd6+ioN2OxB5MuxeM1UneO0hWSvbiEujJ4gjvzEa41fPZrIDF9TrsB jPwDlVz2UzmywbmI7Da3pK40BN0S5FehdPvlmJXKRXOAPorjvGHJvpnzJELqupHbdbTs z7ow== X-Gm-Message-State: ALoCoQmFeH2TvJ03pP3d4WZ1m35sirhwN4EFrPvTB4y99EgORcaOOnt8FyVCaPwmrIRnycMXLh3/ X-Received: by 10.70.89.199 with SMTP id bq7mr32439880pdb.168.1437757577995; Fri, 24 Jul 2015 10:06:17 -0700 (PDT) Received: from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id ra10sm15635403pab.19.2015.07.24.10.06.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Jul 2015 10:06:16 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Date: Fri, 24 Jul 2015 10:06:14 -0700 Message-Id: <1437757584-15502-2-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1437757584-15502-1-git-send-email-stephen@networkplumber.org> References: <1437757584-15502-1-git-send-email-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH 01/11] eth: move queue check for rx_queue_count 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, 24 Jul 2015 17:06:19 -0000 All implemenations of rx_queue_count need to check for queue_id being valid, therefore move the test to common code. Also, add missing queue validation for rx_descriptor_done Signed-off-by: Stephen Hemminger --- drivers/net/e1000/em_rxtx.c | 5 ----- drivers/net/e1000/igb_rxtx.c | 5 ----- drivers/net/i40e/i40e_rxtx.c | 5 ----- drivers/net/ixgbe/ixgbe_rxtx.c | 5 ----- lib/librte_ether/rte_ethdev.c | 11 +++++++++++ 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c index 3b8776d..88ad7d7 100644 --- a/drivers/net/e1000/em_rxtx.c +++ b/drivers/net/e1000/em_rxtx.c @@ -1454,11 +1454,6 @@ eth_em_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) struct em_rx_queue *rxq; uint32_t desc = 0; - if (rx_queue_id >= dev->data->nb_rx_queues) { - PMD_RX_LOG(DEBUG, "Invalid RX queue_id=%d", rx_queue_id); - return 0; - } - rxq = dev->data->rx_queues[rx_queue_id]; rxdp = &(rxq->rx_ring[rxq->rx_tail]); diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c index 3a31b21..2a3c41f 100644 --- a/drivers/net/e1000/igb_rxtx.c +++ b/drivers/net/e1000/igb_rxtx.c @@ -1543,11 +1543,6 @@ eth_igb_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) struct igb_rx_queue *rxq; uint32_t desc = 0; - if (rx_queue_id >= dev->data->nb_rx_queues) { - PMD_RX_LOG(ERR, "Invalid RX queue id=%d", rx_queue_id); - return 0; - } - rxq = dev->data->rx_queues[rx_queue_id]; rxdp = &(rxq->rx_ring[rxq->rx_tail]); diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 891a221..5503ed9 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -2547,11 +2547,6 @@ i40e_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) struct i40e_rx_queue *rxq; uint16_t desc = 0; - if (unlikely(rx_queue_id >= dev->data->nb_rx_queues)) { - PMD_DRV_LOG(ERR, "Invalid RX queue id %u", rx_queue_id); - return 0; - } - rxq = dev->data->rx_queues[rx_queue_id]; rxdp = &(rxq->rx_ring[rxq->rx_tail]); while ((desc < rxq->nb_rx_desc) && diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index af7e222..9a14d72 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -2598,11 +2598,6 @@ ixgbe_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) struct ixgbe_rx_queue *rxq; uint32_t desc = 0; - if (rx_queue_id >= dev->data->nb_rx_queues) { - PMD_RX_LOG(ERR, "Invalid RX queue id=%d", rx_queue_id); - return 0; - } - rxq = dev->data->rx_queues[rx_queue_id]; rxdp = &(rxq->rx_ring[rxq->rx_tail]); diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 8751801..f46426e 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -122,6 +122,7 @@ } \ } while (0) + static const char *MZ_RTE_ETH_DEV_DATA = "rte_eth_dev_data"; struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS]; static struct rte_eth_dev_data *rte_eth_dev_data; @@ -2910,6 +2911,11 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id) VALID_PORTID_OR_ERR_RET(port_id, 0); + if (queue_id >= dev->data->nb_rx_queues) { + PMD_RX_LOG(ERR, "Invalid RX queue id=%d", queue_id); + return 0; + } + dev = &rte_eth_devices[port_id]; FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, 0); return (*dev->dev_ops->rx_queue_count)(dev, queue_id); @@ -2922,6 +2928,11 @@ rte_eth_rx_descriptor_done(uint8_t port_id, uint16_t queue_id, uint16_t offset) VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + if (queue_id >= dev->data->nb_rx_queues) { + PMD_RX_LOG(ERR, "Invalid RX queue id=%d", queue_id); + return 0; + } + dev = &rte_eth_devices[port_id]; FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_done, -ENOTSUP); return (*dev->dev_ops->rx_descriptor_done)(dev->data->rx_queues[queue_id], -- 2.1.4