From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Subject: [dpdk-dev] [PATCH 2/5] net/netvsc: allow tuning latency with devargs
Date: Thu, 30 Aug 2018 15:35:09 -0700 [thread overview]
Message-ID: <20180830223512.21297-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20180830223512.21297-1-stephen@networkplumber.org>
From: Stephen Hemminger <sthemmin@microsoft.com>
Allow overriding default guest to host latency on per device basis
with devargs.
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
doc/guides/nics/netvsc.rst | 16 +++++++++
drivers/net/netvsc/hn_ethdev.c | 62 +++++++++++++++++++++++++++++++---
drivers/net/netvsc/hn_var.h | 1 +
3 files changed, 75 insertions(+), 4 deletions(-)
diff --git a/doc/guides/nics/netvsc.rst b/doc/guides/nics/netvsc.rst
index 345f393c24ba..cc07ce46f885 100644
--- a/doc/guides/nics/netvsc.rst
+++ b/doc/guides/nics/netvsc.rst
@@ -103,3 +103,19 @@ The following prerequisites apply:
* Linux kernel support for UIO on vmbus is done with the uio_hv_generic driver.
Full support of multiple queues requires the 4.17 kernel. It is possible
to use the netvsc PMD with 4.16 kernel but it is limited to a single queue.
+
+
+Netvsc PMD arguments
+--------------------
+
+The user can specify below argument in devargs.
+
+#. ``latency``:
+
+ A netvsc device uses a mailbox page to indicate to the host that there
+ is something in the transmit queue. The host scans this page at a
+ periodic interval. This parameter allows adjusting the value that
+ is used by the host. Smaller values improve transmit latency, and larger
+ values save CPU cycles. This parameter is in microseconds.
+ If the value is too large or too small it will be
+ ignored by the host. (Default: 50)
diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index 2200ee319f98..97e4b0da4410 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -14,7 +14,9 @@
#include <rte_memcpy.h>
#include <rte_string_fns.h>
#include <rte_memzone.h>
+#include <rte_devargs.h>
#include <rte_malloc.h>
+#include <rte_kvargs.h>
#include <rte_atomic.h>
#include <rte_branch_prediction.h>
#include <rte_ether.h>
@@ -131,6 +133,55 @@ eth_dev_vmbus_release(struct rte_eth_dev *eth_dev)
eth_dev->intr_handle = NULL;
}
+/* handle "latency=X" from devargs */
+static int hn_set_latency(const char *key, const char *value, void *opaque)
+{
+ struct hn_data *hv = opaque;
+ char *endp = NULL;
+ unsigned long lat;
+
+ errno = 0;
+ lat = strtoul(value, &endp, 0);
+
+ if (*value == '\0' || *endp != '\0') {
+ PMD_DRV_LOG(ERR, "invalid parameter %s=%s", key, value);
+ return -EINVAL;
+ }
+
+ PMD_DRV_LOG(DEBUG, "set latency %lu usec", lat);
+
+ hv->latency = lat * 1000; /* usec to nsec */
+ return 0;
+}
+
+/* Parse device arguments */
+static int hn_parse_args(const struct rte_eth_dev *dev)
+{
+ struct hn_data *hv = dev->data->dev_private;
+ struct rte_devargs *devargs = dev->device->devargs;
+ static const char * const valid_keys[] = {
+ "latency",
+ NULL
+ };
+ struct rte_kvargs *kvlist;
+
+ if (!devargs)
+ return 0;
+
+ PMD_INIT_LOG(DEBUG, "device args %s %s",
+ devargs->name, devargs->args);
+
+ kvlist = rte_kvargs_parse(devargs->args, valid_keys);
+ if (!kvlist) {
+ PMD_DRV_LOG(NOTICE, "invalid parameters");
+ return -EINVAL;
+ }
+
+ rte_kvargs_process(kvlist, "latency", hn_set_latency, hv);
+ rte_kvargs_free(kvlist);
+ return 0;
+}
+
/* Update link status.
* Note: the DPDK definition of "wait_to_complete"
* means block this call until link is up.
@@ -264,8 +315,7 @@ static int hn_subchan_configure(struct hn_data *hv,
return err;
}
- rte_vmbus_set_latency(hv->vmbus, new_sc,
- HN_CHAN_LATENCY_NS);
+ rte_vmbus_set_latency(hv->vmbus, new_sc, hv->latency);
retry = 0;
chn_index = rte_vmbus_sub_channel_index(new_sc);
@@ -627,14 +677,18 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
hv->rxbuf_res = &vmbus->resource[HV_RECV_BUF_MAP];
hv->chim_res = &vmbus->resource[HV_SEND_BUF_MAP];
hv->port_id = eth_dev->data->port_id;
+ hv->latency = HN_CHAN_LATENCY_NS;
+
+ err = hn_parse_args(eth_dev);
+ if (err)
+ return err;
/* Initialize primary channel input for control operations */
err = rte_vmbus_chan_open(vmbus, &hv->channels[0]);
if (err)
return err;
- rte_vmbus_set_latency(hv->vmbus, hv->channels[0],
- HN_CHAN_LATENCY_NS);
+ rte_vmbus_set_latency(hv->vmbus, hv->channels[0], hv->latency);
hv->primary = hn_rx_queue_alloc(hv, 0,
eth_dev->device->numa_node);
diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h
index b42bd97b9a45..f188f6360f79 100644
--- a/drivers/net/netvsc/hn_var.h
+++ b/drivers/net/netvsc/hn_var.h
@@ -113,6 +113,7 @@ struct hn_data {
uint32_t chim_szmax; /* Max size per buffer */
uint32_t chim_cnt; /* Max packets per buffer */
+ uint32_t latency;
uint32_t nvs_ver;
uint32_t ndis_ver;
uint32_t rndis_agg_size;
--
2.18.0
next prev parent reply other threads:[~2018-08-30 22:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-30 22:35 [dpdk-dev] [PATCH 0/5] netvsc changes for 18.11 Stephen Hemminger
2018-08-30 22:35 ` [dpdk-dev] [PATCH 1/5] bus/vmbus: add devargs support Stephen Hemminger
2018-09-14 12:46 ` Ferruh Yigit
2018-09-14 13:06 ` Gaëtan Rivet
2018-09-14 13:19 ` Ferruh Yigit
2018-09-14 13:58 ` Gaëtan Rivet
2018-09-14 15:21 ` Stephen Hemminger
2018-08-30 22:35 ` Stephen Hemminger [this message]
2018-09-14 12:47 ` [dpdk-dev] [PATCH 2/5] net/netvsc: allow tuning latency with devargs Ferruh Yigit
2018-08-30 22:35 ` [dpdk-dev] [PATCH 3/5] net/netvsc: exhausting transmit descriptors is not an error Stephen Hemminger
2018-08-30 22:35 ` [dpdk-dev] [PATCH 4/5] net/netvsc: implement link state change callback Stephen Hemminger
2018-08-31 8:25 ` Gaëtan Rivet
2018-08-31 15:13 ` Stephen Hemminger
2018-08-30 22:35 ` [dpdk-dev] [PATCH 5/5] net/netvsc: integrated VF support Stephen Hemminger
2018-09-14 12:57 ` Ferruh Yigit
2018-09-14 15:22 ` Stephen Hemminger
2018-08-31 12:04 ` [dpdk-dev] [PATCH 0/5] netvsc changes for 18.11 Ferruh Yigit
2018-08-31 15:15 ` Stephen Hemminger
2018-08-31 16:56 ` Thomas Monjalon
2018-09-14 13:25 ` 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=20180830223512.21297-3-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=sthemmin@microsoft.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).