From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id DE62B5F13 for ; Fri, 31 Aug 2018 00:35:22 +0200 (CEST) Received: by mail-pf1-f193.google.com with SMTP id x17-v6so4534451pfh.5 for ; Thu, 30 Aug 2018 15:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KW+5S+oOCMAgwNoA7ctkJEK+xC7bsKZaj67Hbwz4vUI=; b=ddO/cm9Tf7/rBUA+VO00d2eZMtphyF/zziKNrJyjufU5Yc6xQP46PExBiCHXfIbpyz F+/Ka+vbxtupv1A6qggqu0WJVmRjedi1cXq2dUGuhVldP16g845Uoo9gJl1cBycaBk+i 9fiW52ob28zECBv3gjl8uNUOqcgTkoVfEskVWjfLgpztVdNvjMlBfOWneJbwrQRJQb3K m9J3TEGVtXqlfdY9IGrLpj5gOifylN0y210Hu5WGylPuGA73M6kO0XBdasUUjd4a59U2 SRqEqSa/2Py2oVJgOM6faWnRFMxXk0XcNj3g+3fgSS/vQoilUS14OMpl3niRhBIcDDk6 IsUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KW+5S+oOCMAgwNoA7ctkJEK+xC7bsKZaj67Hbwz4vUI=; b=TwHyYdmHKDs8IvXhb3ikEMUA1ArumuYLGHfyX++i7CTTh6pSxmyIz6pueLk+E0Zu4K X0BVL5cxYBUmRz5OzyIRmADBk6T0WDbzfp+WbQ7ms3R/4Ra6ORAywRGaTRQCjRx6aIxv jW429kn1q3atkVkNYy3Mr68bfPYrGiH2mDoAoKXU4VfHFFN52+teHZ1j6JKAuBEPT66q BMrSmzbFCTTo9AEU5A5zaz/4W7tXuJUUOvep3sG5ZuoK3vWOwU8RpNeVkQNJJJIw59kk Kjdq6XDDj0Ab8XdggMg3NgsJXcw7vp6HcCJAR9AYTq8BIkJzzyDVMqSYvg8fxp2c+kUe gJ9w== X-Gm-Message-State: APzg51BLP/yLy4v5/+6pgaaliHKsIIck6gUG8sTkWCSwFuB5hjfoZH9l 3GerMh7PHm+enzZtHs+8bRS6e8MJj2DYKg== X-Google-Smtp-Source: ANB0VdaZruckkbrIt78oonMg0leijOwGCB8uXJ+y4U5DmJtl0fF6bE/K5G6DcIxqg4ul1Xa92sdajQ== X-Received: by 2002:a62:1f11:: with SMTP id f17-v6mr12585866pff.168.1535668521678; Thu, 30 Aug 2018 15:35:21 -0700 (PDT) Received: from xeon-e3.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id r19-v6sm11746033pgg.39.2018.08.30.15.35.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 15:35:20 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 30 Aug 2018 15:35:09 -0700 Message-Id: <20180830223512.21297-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180830223512.21297-1-stephen@networkplumber.org> References: <20180830223512.21297-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH 2/5] net/netvsc: allow tuning latency with devargs 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: Thu, 30 Aug 2018 22:35:23 -0000 From: Stephen Hemminger Allow overriding default guest to host latency on per device basis with devargs. Signed-off-by: Stephen Hemminger --- 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 #include #include +#include #include +#include #include #include #include @@ -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