From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id A7144282 for ; Fri, 3 Feb 2017 10:37:49 +0100 (CET) Received: by mail-wm0-f46.google.com with SMTP id v77so18916579wmv.0 for ; Fri, 03 Feb 2017 01:37:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=HspFyLz8nchoQenGwmH2nwi7cloF83SrTkljFZtcbfk=; b=RqtTji5APeVoTRKiKBkA7w6kxxw4zOki085xSLbzKbE90IhbahQsRhDzT0sD8ZQHbK sbOfIGwmfNH99O6MRIbJJrEWY25V5iuUwdjmQjhvm3Y2xpL0uAJX5rDQ+epILi2LOJI+ RRuF+cfu+4YvhKX396ZmhhrPkndnVOiaBxl4FcAGCm1dRElv3VmRWWwKimfYHTRkb2B3 ZOHlly280aQhTUPx/PT28zqx7neyM5QesG6Rm2dPqlc0XmjUlqir4KErOAbpZHVgISYH j4AyYJ0f4NnZ7t71CYYxHvz9kwW/sN84GxqzVQxjvy8nnprCNOEZQgRb98pmBq7LNyPC T64g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=HspFyLz8nchoQenGwmH2nwi7cloF83SrTkljFZtcbfk=; b=a7owET4oJiFgRc8gv+UWBg0aw+pLFxB2r6PX6QWJK1/tR2UY1u+82WMDJjiL0/3HHx 42wDqBwMYw+s0DpK9LQ+yrgkrHYAXwLlD91+nsSZL3ACfJ4B/qknVS6TaYzTq4Poykks d93aX4pCMNc/3dPwq7H9q4cfzAKRswxTnoz7/dg7PD6e8aKQ/dMg5wvhrVdJ6YaW0LN0 +glkUOcqNNPwjE2DxlZYwCEF82e1LfMcQqQ6cd4kSmmKkq1pg47EDDUPRxFybMas9Ghj P5LZkGFrb61GO/EOeobQTCDztmcVdKD++lb6rG3Z6X+2GYo/PbMO2ypzyS6T/QQlt+dr IQmQ== X-Gm-Message-State: AIkVDXKLOHThDRu+FrGg9VT9Gudni0YJFXEcztPzB9P4EJsnVe54+OnuMCjBsrHXi+CMQCTM X-Received: by 10.223.131.99 with SMTP id 90mr11419939wrd.146.1486114669083; Fri, 03 Feb 2017 01:37:49 -0800 (PST) Received: from paques.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id c202sm2047676wmd.10.2017.02.03.01.37.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2017 01:37:48 -0800 (PST) Date: Fri, 3 Feb 2017 10:37:40 +0100 From: Pascal Mazon To: Keith Wiles Cc: dev@dpdk.org Message-ID: <20170203103740.60e76f0e@paques.dev.6wind.com> In-Reply-To: <20170202223330.39240-2-keith.wiles@intel.com> References: <20170202223330.39240-1-keith.wiles@intel.com> <20170202223330.39240-2-keith.wiles@intel.com> Organization: 6WIND X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 2/5] net/tap: fix multi-queue support 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: , X-List-Received-Date: Fri, 03 Feb 2017 09:37:49 -0000 On Thu, 2 Feb 2017 16:33:27 -0600 Keith Wiles wrote: > Signed-off-by: Keith Wiles > --- > drivers/net/tap/rte_eth_tap.c | 93 > ++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), > 45 deletions(-) > > diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c > index 3f179c3..9ed7a87 100644 > --- a/drivers/net/tap/rte_eth_tap.c > +++ b/drivers/net/tap/rte_eth_tap.c > @@ -115,10 +115,9 @@ struct pmd_internals { > * supplied name. > */ > static int > -tun_alloc(char *name) > +tun_alloc(char *name, uint16_t qid) > { > struct ifreq ifr; > - unsigned int features; > int fd; > > memset(&ifr, 0, sizeof(struct ifreq)); > @@ -133,55 +132,57 @@ tun_alloc(char *name) > goto error; > } > > - /* Grab the TUN features to verify we can work */ > - if (ioctl(fd, TUNGETFEATURES, &features) < 0) { > - RTE_LOG(ERR, PMD, "Unable to get TUN/TAP features\n"); > - goto error; > - } > - RTE_LOG(DEBUG, PMD, "TUN/TAP Features %08x\n", features); > + /* This can only be done once per interface */ > + if (qid == 0) { > + unsigned int features; > + > + /* Grab the TUN features to verify we can work */ > + if (ioctl(fd, TUNGETFEATURES, &features) < 0) { > + RTE_LOG(ERR, PMD, "Unable to get TUN/TAP > features\n"); > + goto error; > + } > + RTE_LOG(DEBUG, PMD, "TUN/TAP Features %08x\n", features); > > #ifdef IFF_MULTI_QUEUE > - if (!(features & IFF_MULTI_QUEUE) && (RTE_PMD_TAP_MAX_QUEUES > 1)) { > - RTE_LOG(DEBUG, PMD, "TUN/TAP device only one queue\n"); > - goto error; > - } else if ((features & IFF_ONE_QUEUE) && > - (RTE_PMD_TAP_MAX_QUEUES == 1)) { > - ifr.ifr_flags |= IFF_ONE_QUEUE; > - RTE_LOG(DEBUG, PMD, "Single queue only support\n"); > - } else { > - ifr.ifr_flags |= IFF_MULTI_QUEUE; > - RTE_LOG(DEBUG, PMD, "Multi-queue support for %d queues\n", > - RTE_PMD_TAP_MAX_QUEUES); > - } > + if (!(features & IFF_MULTI_QUEUE) && (RTE_PMD_TAP_MAX_QUEUES > > 1)) { > + RTE_LOG(DEBUG, PMD, "TUN/TAP device only one > queue\n"); > + goto error; > + } else if ((features & IFF_ONE_QUEUE) && > + (RTE_PMD_TAP_MAX_QUEUES == 1)) { > + ifr.ifr_flags |= IFF_ONE_QUEUE; > + RTE_LOG(DEBUG, PMD, "Single queue only support\n"); > + } else { > + ifr.ifr_flags |= IFF_MULTI_QUEUE; > + RTE_LOG(DEBUG, PMD, "Multi-queue support for %d > queues\n", > + RTE_PMD_TAP_MAX_QUEUES); > + } > #else > - if (RTE_PMD_TAP_MAX_QUEUES > 1) { > - RTE_LOG(DEBUG, PMD, "TUN/TAP device only one queue\n"); > - goto error; > - } else { > - ifr.ifr_flags |= IFF_ONE_QUEUE; > - RTE_LOG(DEBUG, PMD, "Single queue only support\n"); > - } > + if (RTE_PMD_TAP_MAX_QUEUES > 1) { > + RTE_LOG(DEBUG, PMD, "TUN/TAP device only one > queue\n"); > + goto error; > + } else { > + ifr.ifr_flags |= IFF_ONE_QUEUE; > + RTE_LOG(DEBUG, PMD, "Single queue only support\n"); > + } > #endif > > - /* Set the TUN/TAP configuration and get the name if needed */ > - if (ioctl(fd, TUNSETIFF, (void *)&ifr) < 0) { > - RTE_LOG(ERR, PMD, "Unable to set TUNSETIFF for %s\n", > - ifr.ifr_name); > - perror("TUNSETIFF"); > - goto error; > - } > + /* Set the TUN/TAP configuration and get the name if needed > */ > + if (ioctl(fd, TUNSETIFF, (void *)&ifr) < 0) { > + RTE_LOG(ERR, PMD, "Unable to set TUNSETIFF for %s\n", > + ifr.ifr_name); > + perror("TUNSETIFF"); > + goto error; > + } > > - /* Always set the file descriptor to non-blocking */ > - if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { > - RTE_LOG(ERR, PMD, "Unable to set to nonblocking\n"); > - perror("F_SETFL, NONBLOCK"); > - goto error; > + /* Always set the file descriptor to non-blocking */ > + if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { > + RTE_LOG(WARNING, PMD, "Unable to set %s to > nonblocking\n", > + ifr.ifr_name); > + perror("F_SETFL, NONBLOCK"); > + goto error; > + } > } > > - /* If the name is different that new name as default */ > - if (name && strcmp(name, ifr.ifr_name)) > - snprintf(name, RTE_ETH_NAME_MAX_LEN - 1, "%s", ifr.ifr_name); > - > return fd; > > error: > @@ -512,7 +513,7 @@ tap_setup_queue(struct rte_eth_dev *dev, > if (fd < 0) { > RTE_LOG(INFO, PMD, "Add queue to TAP %s for qid > %d\n", pmd->name, qid); > - fd = tun_alloc(pmd->name); > + fd = tun_alloc(pmd->name, qid); > if (fd < 0) { > RTE_LOG(ERR, PMD, "tun_alloc(%s) failed\n", > pmd->name); return -1; > @@ -711,7 +712,7 @@ eth_dev_tap_create(const char *name, char *tap_name) > snprintf(dev->data->name, sizeof(dev->data->name), "%s", name); > > /* Create the first Tap device */ > - fd = tun_alloc(tap_name); > + fd = tun_alloc(tap_name, 0); > if (fd < 0) { > RTE_LOG(ERR, PMD, "tun_alloc() failed\n"); > goto error_exit; > @@ -739,6 +740,8 @@ eth_dev_tap_create(const char *name, char *tap_name) > error_exit: > RTE_PMD_DEBUG_TRACE("Unable to initialize %s\n", name); > > + if (fd > 0) > + close(fd); > rte_free(data); > rte_free(pmd); > The patch looks good to me. Can you maybe detail in the commit log that now queue 0 is created while probing, while other queues are handled through tap_setup_queue() only? Pascal