From: "Wiles, Keith" <keith.wiles@intel.com>
To: Pascal Mazon <pascal.mazon@6wind.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 2/5] net/tap: fix multi-queue support
Date: Fri, 3 Feb 2017 20:32:33 +0000 [thread overview]
Message-ID: <51B6DC50-F585-4979-8F68-BC4B160A9D60@intel.com> (raw)
In-Reply-To: <20170203103740.60e76f0e@paques.dev.6wind.com>
> On Feb 3, 2017, at 3:37 AM, Pascal Mazon <pascal.mazon@6wind.com> wrote:
>
> On Thu, 2 Feb 2017 16:33:27 -0600
> Keith Wiles <keith.wiles@intel.com> wrote:
>
>> Signed-off-by: Keith Wiles <keith.wiles@intel.com>
>> ---
>> 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?
In my changes before your patch set I had removed creating queue 0 at probe and only created the interface/queue at queue setup time. It would have required a more changes compared to your patches and the original code. :-(
>
> Pascal
Regards,
Keith
next prev parent reply other threads:[~2017-02-03 20:32 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-02 22:33 [dpdk-dev] [PATCH 1/5] nic/tap: fix tap docs for device name Keith Wiles
2017-02-02 22:33 ` [dpdk-dev] [PATCH 2/5] net/tap: fix multi-queue support Keith Wiles
2017-02-03 9:37 ` Pascal Mazon
2017-02-03 20:32 ` Wiles, Keith [this message]
2017-02-02 22:33 ` [dpdk-dev] [PATCH 3/5] net/tap: remove redundant fds array Keith Wiles
2017-02-03 9:38 ` Pascal Mazon
2017-02-02 22:33 ` [dpdk-dev] [PATCH 4/5] net/tap: fix up log message to correct channel Keith Wiles
2017-02-03 9:45 ` Pascal Mazon
2017-02-02 22:33 ` [dpdk-dev] [PATCH 5/5] net/tap: remove unused variable and minor cleanup Keith Wiles
2017-02-03 9:47 ` Pascal Mazon
2017-02-03 9:32 ` [dpdk-dev] [PATCH 1/5] nic/tap: fix tap docs for device name Pascal Mazon
2017-02-03 11:48 ` Ferruh Yigit
2017-02-05 16:05 ` [dpdk-dev] [PATCH v2 1/6] net/tap: " Keith Wiles
2017-02-05 16:05 ` [dpdk-dev] [PATCH v2 2/6] net/tap: remove redundant fds array Keith Wiles
2017-02-05 16:05 ` [dpdk-dev] [PATCH v2 3/6] net/tap: remove unused variable and minor cleanup Keith Wiles
2017-02-05 16:05 ` [dpdk-dev] [PATCH v2 4/6] net/tap: fix multi-queue support Keith Wiles
2017-02-06 15:45 ` Pascal Mazon
2017-02-06 15:57 ` Wiles, Keith
2017-02-05 16:05 ` [dpdk-dev] [PATCH v2 5/6] net/tap: cleanup log messages Keith Wiles
2017-02-05 16:05 ` [dpdk-dev] [PATCH v2 6/6] net/tap: link set down must be before close Keith Wiles
2017-02-06 15:57 ` Pascal Mazon
2017-02-06 16:03 ` Wiles, Keith
2017-02-06 19:40 ` [dpdk-dev] [PATCH v3 1/7] net/tap: fix tap docs for device name Keith Wiles
2017-02-06 19:40 ` [dpdk-dev] [PATCH v3 2/7] net/tap: remove redundant fds array Keith Wiles
2017-02-06 19:40 ` [dpdk-dev] [PATCH v3 3/7] net/tap: remove unused variable and minor cleanup Keith Wiles
2017-02-06 19:40 ` [dpdk-dev] [PATCH v3 4/7] net/tap: fix multi-queue support Keith Wiles
2017-02-06 19:40 ` [dpdk-dev] [PATCH v3 5/7] net/tap: cleanup log messages Keith Wiles
2017-02-06 19:40 ` [dpdk-dev] [PATCH v3 6/7] net/tap: link set down must be done before close Keith Wiles
2017-02-06 19:40 ` [dpdk-dev] [PATCH v3 7/7] net/tap: move closing fds to pmd close from pmd stop Keith Wiles
2017-02-07 8:51 ` Pascal Mazon
2017-02-07 14:06 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51B6DC50-F585-4979-8F68-BC4B160A9D60@intel.com \
--to=keith.wiles@intel.com \
--cc=dev@dpdk.org \
--cc=pascal.mazon@6wind.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).