From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 25D84A04B1; Wed, 23 Sep 2020 10:25:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B11921DBB3; Wed, 23 Sep 2020 10:25:33 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id A72C21DBA5 for ; Wed, 23 Sep 2020 10:25:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600849531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=idAx+/3uY2+Szf+k3k7+NydYHqcr91lVqfw5VjvvlQE=; b=SBHD/QdeyB9yoICcQgrrSZprAU+JkQ99VAFnl0SM12W9D9BaMdRxjHHT8YKGMDi6xBcnNK ql5VcI18sEKlDYXk7WfTXIlGT6TUQygEXZp3VD12J/btUMDa6k7NtTvp0g2qScbpUWv016 Lwv45cYxz4pNOnBJPpnB0wgS/iFA/Dw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-596-n6k7J1b8Pk2OzAxgZFPOkQ-1; Wed, 23 Sep 2020 04:25:27 -0400 X-MC-Unique: n6k7J1b8Pk2OzAxgZFPOkQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDA4A85C734; Wed, 23 Sep 2020 08:25:25 +0000 (UTC) Received: from [10.36.110.9] (unknown [10.36.110.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C00F91002388; Wed, 23 Sep 2020 08:25:23 +0000 (UTC) To: Cheng Jiang , chenbo.xia@intel.com, zhihong.wang@intel.com, john.mcnamara@intel.com, marko.kovacevic@intel.com Cc: dev@dpdk.org, patrick.fu@intel.com References: <20200910064351.35513-1-Cheng1.jiang@intel.com> <20200910064351.35513-2-Cheng1.jiang@intel.com> From: Maxime Coquelin Autocrypt: addr=maxime.coquelin@redhat.com; keydata= mQINBFOEQQIBEADjNLYZZqghYuWv1nlLisptPJp+TSxE/KuP7x47e1Gr5/oMDJ1OKNG8rlNg kLgBQUki3voWhUbMb69ybqdMUHOl21DGCj0BTU3lXwapYXOAnsh8q6RRM+deUpasyT+Jvf3a gU35dgZcomRh5HPmKMU4KfeA38cVUebsFec1HuJAWzOb/UdtQkYyZR4rbzw8SbsOemtMtwOx YdXodneQD7KuRU9IhJKiEfipwqk2pufm2VSGl570l5ANyWMA/XADNhcEXhpkZ1Iwj3TWO7XR uH4xfvPl8nBsLo/EbEI7fbuUULcAnHfowQslPUm6/yaGv6cT5160SPXT1t8U9QDO6aTSo59N jH519JS8oeKZB1n1eLDslCfBpIpWkW8ZElGkOGWAN0vmpLfdyiqBNNyS3eGAfMkJ6b1A24un /TKc6j2QxM0QK4yZGfAxDxtvDv9LFXec8ENJYsbiR6WHRHq7wXl/n8guyh5AuBNQ3LIK44x0 KjGXP1FJkUhUuruGyZsMrDLBRHYi+hhDAgRjqHgoXi5XGETA1PAiNBNnQwMf5aubt+mE2Q5r qLNTgwSo2dpTU3+mJ3y3KlsIfoaxYI7XNsPRXGnZi4hbxmeb2NSXgdCXhX3nELUNYm4ArKBP LugOIT/zRwk0H0+RVwL2zHdMO1Tht1UOFGfOZpvuBF60jhMzbQARAQABtCxNYXhpbWUgQ29x dWVsaW4gPG1heGltZS5jb3F1ZWxpbkByZWRoYXQuY29tPokCOAQTAQIAIgUCV3u/5QIbAwYL CQgHAwIGFQ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mlRmm2RdN7iCZfbyP3dvFQTzQ4ySquuPkIGcOOHrvZzxbRjzMx1 Mwqu3GQ= Message-ID: Date: Wed, 23 Sep 2020 10:25:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200910064351.35513-2-Cheng1.jiang@intel.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US Subject: Re: [dpdk-dev] [PATCH v1 1/4] example/vhost: add async vhost driver args parsing function 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" On 9/10/20 8:43 AM, Cheng Jiang wrote: > This patch is to add async vhost driver arguments parsing function > for CBDMA channel. With these arguments vhost sample can be set to > use CBDMA or CPU for enqueue operation and bind vhost device with > specific CBDMA channel to accelerate vhost data-path. > > Signed-off-by: Cheng Jiang > --- > examples/vhost/main.c | 133 +++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 131 insertions(+), 2 deletions(-) > > diff --git a/examples/vhost/main.c b/examples/vhost/main.c > index e1578e795..011e3da21 100644 > --- a/examples/vhost/main.c > +++ b/examples/vhost/main.c > @@ -24,6 +24,9 @@ > #include > #include > #include > +#include > +#include > +#include > > #include "main.h" > > @@ -58,6 +61,12 @@ > /* Maximum long option length for option parsing. */ > #define MAX_LONG_OPT_SZ 64 > > +#define IOAT_RING_SIZE 4096 > + > +#define MAX_ENQUEUED_SIZE 2048 > + > +#define MAX_VHOST_DEVICE 1024 > + > /* mask of enabled ports */ > static uint32_t enabled_port_mask = 0; > > @@ -96,6 +105,21 @@ static int dequeue_zero_copy; > > static int builtin_net_driver; > > +static int async_vhost_driver; > + > +struct dma_info { > + struct rte_pci_addr addr; > + uint16_t dev_id; > + bool is_valid; > +}; > + > +struct dma_for_vhost { > + struct dma_info dmas[RTE_MAX_QUEUES_PER_PORT * 2]; > + uint16_t nr; > +}; > + > +static struct dma_for_vhost dma_bind[MAX_VHOST_DEVICE]; > + > /* Specify timeout (in useconds) between retries on RX. */ > static uint32_t burst_rx_delay_time = BURST_RX_WAIT_US; > /* Specify the number of retries on RX. */ > @@ -182,6 +206,97 @@ struct mbuf_table lcore_tx_queue[RTE_MAX_LCORE]; > / US_PER_S * BURST_TX_DRAIN_US) > #define VLAN_HLEN 4 > > +static inline int > +open_dma(const char *value, void *dma_bind_info) > +{ > + struct dma_for_vhost *dma_info = dma_bind_info; > + char *input = strndup(value, strlen(value) + 1); > + char *addrs = input; > + char *ptrs[2]; > + char *start, *end, *substr; > + int64_t vid, vring_id; > + struct rte_ioat_rawdev_config config; > + struct rte_rawdev_info info = { .dev_private = &config }; > + char name[32]; > + int dev_id; > + int ret = 0; > + uint16_t i = 0; > + > + while (isblank(*addrs)) > + addrs++; > + if (*addrs == '\0') { > + ret = -1; > + goto out; > + } > + > + /* process DMA devices within bracket. */ > + addrs++; > + substr = strtok(addrs, ";]"); > + if (!substr) { > + ret = -1; > + goto out; > + } > + char *dma_arg[MAX_VHOST_DEVICE]; > + rte_strsplit(substr, strlen(substr), dma_arg, MAX_VHOST_DEVICE, ','); > + do { > + char *arg_temp = dma_arg[i]; > + rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@'); > + > + start = strstr(ptrs[0], "txd"); > + if (start == NULL) { > + ret = -1; > + goto out; > + } > + > + start += 3; > + vid = strtol(start, &end, 0); > + if (end == start) { > + ret = -1; > + goto out; > + } > + > + vring_id = 0 + VIRTIO_RXQ; > + if (rte_pci_addr_parse(ptrs[1], > + &(dma_info + vid)->dmas[vring_id].addr) < 0) { > + ret = -1; > + goto out; > + } > + > + rte_pci_device_name(&(dma_info + vid)->dmas[vring_id].addr, > + name, sizeof(name)); > + dev_id = rte_rawdev_get_dev_id(name); > + if (dev_id == (uint16_t)(-ENODEV) || > + dev_id == (uint16_t)(-EINVAL)) { > + ret = -1; > + goto out; > + } > + > + if (rte_rawdev_info_get(dev_id, &info) < 0 || > + strstr(info.driver_name, "ioat") == NULL) { > + ret = -1; > + goto out; > + } > + > + (dma_info + vid)->dmas[vring_id].dev_id = dev_id; > + (dma_info + vid)->dmas[vring_id].is_valid = true; > + config.ring_size = IOAT_RING_SIZE; > + if (rte_rawdev_configure(dev_id, &info) < 0) { > + ret = -1; > + goto out; > + } > + rte_rawdev_start(dev_id); > + > + dma_info->nr++; > + > + arg_temp = strtok(NULL, ";]"); > + i++; > + } while (dma_arg[i]); > + > +out: > + free(input); > + return ret; > +} > + I think this is purely Intel specifics, so using generic "dma" name is not a good idea. Also, as this is HW specific, it should be moved to a dedicated file which would only be compiled if all dependencies are met. (it does not even build on X86: http://mails.dpdk.org/archives/test-report/2020-September/151519.html) > /* > * Builds up the correct configuration for VMDQ VLAN pool map > * according to the pool & queue limits. > @@ -485,6 +600,8 @@ us_vhost_parse_args(int argc, char **argv) > {"client", no_argument, &client_mode, 1}, > {"dequeue-zero-copy", no_argument, &dequeue_zero_copy, 1}, > {"builtin-net-driver", no_argument, &builtin_net_driver, 1}, > + {"async_vhost_driver", no_argument, &async_vhost_driver, 1}, Shouldn't it be in patch 2 where it is used? Also, I wonder whether it is really necessary, as as soon as you pass dmas parameter you know you'll want to use async mode, no? > + {"dmas", required_argument, NULL, 0}, > {NULL, 0, 0, 0}, > }; > > @@ -620,13 +737,25 @@ us_vhost_parse_args(int argc, char **argv) > "socket-file", MAX_LONG_OPT_SZ)) { > if (us_vhost_parse_socket_path(optarg) == -1) { > RTE_LOG(INFO, VHOST_CONFIG, > - "Invalid argument for socket name (Max %d characters)\n", > - PATH_MAX); > + "Invalid argument for socket name (Max %d characters)\n", > + PATH_MAX); > us_vhost_usage(prgname); > return -1; > } > } > > + if (!strncmp(long_option[option_index].name, > + "dmas", MAX_LONG_OPT_SZ)) { > + if (open_dma(optarg, &dma_bind) == -1) { > + if (*optarg == -1) { > + RTE_LOG(INFO, VHOST_CONFIG, > + "Wrong DMA args\n"); > + us_vhost_usage(prgname); You need to update us_vhost_usage() to document the new arguments. > + return -1; > + } > + } > + } > + > break; > > /* Invalid option - print options. */ >