From patchwork Thu Oct 26 09:51:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pengzhen Liu X-Patchwork-Id: 30939 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E2EF41BA60; Thu, 26 Oct 2017 11:16:30 +0200 (CEST) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id 1B5131B767 for ; Thu, 26 Oct 2017 11:16:27 +0200 (CEST) Received: from 172.30.72.60 (EHLO DGGEMS401-HUB.china.huawei.com) ([172.30.72.60]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DJY54629; Thu, 26 Oct 2017 17:16:17 +0800 (CST) Received: from localhost (10.175.126.192) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.361.1; Thu, 26 Oct 2017 17:15:20 +0800 From: Pengzhen Liu To: CC: , , Keith Wiles , Ferruh Yigit Date: Thu, 26 Oct 2017 17:51:33 +0800 Message-ID: <1509011493-26531-1-git-send-email-liupengzhen3@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 X-Originating-IP: [10.175.126.192] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.59F1A7E1.00BB, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 97ea9d47bcc7d74a2e67f3abd4e3a253 Subject: [dpdk-dev] [PATCH] 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. Fixes: 02f96a0a82d1 ("net/tap: add TUN/TAP device PMD") Signed-off-by: Keith Wiles Signed-off-by: Ferruh Yigit --- 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 @@ struct pmd_internals { } } } - dev->data->rx_queues[qid] = rx; - dev->data->tx_queues[qid] = tx; rx->fd = fd; tx->fd = fd; @@ -438,6 +436,26 @@ struct pmd_internals { } 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 @@ struct pmd_internals { 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 @@ struct pmd_internals { 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;