From patchwork Mon Jan 30 20:54:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 20079 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 6DE023989; Mon, 30 Jan 2017 21:54:51 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 985083237 for ; Mon, 30 Jan 2017 21:54:49 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 30 Jan 2017 12:54:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.33,312,1477983600"; d="scan'208"; a="1100875818" Received: from sivswdev02.ir.intel.com ([10.237.217.46]) by fmsmga001.fm.intel.com with ESMTP; 30 Jan 2017 12:54:47 -0800 From: Ferruh Yigit To: Keith Wiles Cc: dev@dpdk.org, Ferruh Yigit Date: Mon, 30 Jan 2017 20:54:45 +0000 Message-Id: <20170130205445.7527-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20170129021205.36860-1-keith.wiles@intel.com> References: <20170129021205.36860-1-keith.wiles@intel.com> Subject: [dpdk-dev] [PATCH v2] net/tap: fix invalid queue file descriptor 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: Keith Wiles Rx and Tx queues share the common tap file descriptor, but save this value separately. Setting up Rx/Tx queue sets up both queues, release_queue close the tap file but update file descriptor only for that queue. This makes other queue's file descriptor invalid. As a workaround, prevent release_queue callback to be called by default. This is done by separating Rx/Tx setup functions, so that each only setup its own queue, this prevents rte_eth_rx/tx_queue_setup() calling release_queue before setup_queue. Signed-off-by: Keith Wiles Signed-off-by: Ferruh Yigit Acked-by: Keith Wiles --- drivers/net/tap/rte_eth_tap.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index c0afc2d..91f63f5 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -428,8 +428,6 @@ tap_setup_queue(struct rte_eth_dev *dev, } } } - dev->data->rx_queues[qid] = rx; - dev->data->tx_queues[qid] = tx; rx->fd = fd; tx->fd = fd; @@ -438,6 +436,26 @@ tap_setup_queue(struct rte_eth_dev *dev, } static int +rx_setup_queue(struct rte_eth_dev *dev, + struct pmd_internals *internals, + uint16_t qid) +{ + dev->data->rx_queues[qid] = &internals->rxq[qid]; + + return tap_setup_queue(dev, internals, qid); +} + +static int +tx_setup_queue(struct rte_eth_dev *dev, + struct pmd_internals *internals, + uint16_t qid) +{ + dev->data->tx_queues[qid] = &internals->txq[qid]; + + return tap_setup_queue(dev, internals, qid); +} + +static int tap_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, uint16_t nb_rx_desc __rte_unused, @@ -469,7 +487,7 @@ tap_rx_queue_setup(struct rte_eth_dev *dev, return -ENOMEM; } - fd = tap_setup_queue(dev, internals, rx_queue_id); + fd = rx_setup_queue(dev, internals, rx_queue_id); if (fd == -1) return -1; @@ -493,7 +511,7 @@ tap_tx_queue_setup(struct rte_eth_dev *dev, if (tx_queue_id >= internals->nb_queues) return -1; - ret = tap_setup_queue(dev, internals, tx_queue_id); + ret = tx_setup_queue(dev, internals, tx_queue_id); if (ret == -1) return -1;