From 9d071e5ce75b3fdb0d04fd44b6fc4538c913f939 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 9 Aug 2018 10:50:06 -0700 Subject: [PATCH] bus/vmbus: add host latency tuning function Add vmbus API to allow tuning the scan interval on the host side. Signed-off-by: Stephen Hemminger --- drivers/bus/vmbus/rte_bus_vmbus.h | 15 ++++++++++++ drivers/bus/vmbus/rte_bus_vmbus_version.map | 7 ++++++ drivers/bus/vmbus/vmbus_channel.c | 26 +++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h b/drivers/bus/vmbus/rte_bus_vmbus.h index 4a2c1f6fd9..2839fef5b2 100644 --- a/drivers/bus/vmbus/rte_bus_vmbus.h +++ b/drivers/bus/vmbus/rte_bus_vmbus.h @@ -364,6 +364,21 @@ void rte_vmbus_chan_signal_read(struct vmbus_channel *chan, uint32_t bytes_read) */ uint16_t rte_vmbus_sub_channel_index(const struct vmbus_channel *chan); +/** + * Set the host monitor latency hint + * + * @param dev + * VMBUS device + * @param chan + * Pointer to vmbus_channel structure. + * @param latency + * Approximate wait period between hypervisor examinations of + * the trigger page (in nanoseconds). + */ +void rte_vmbus_set_latency(const struct rte_vmbus_device *dev, + const struct vmbus_channel *chan, + uint32_t latency); + /** * Register a VMBUS driver. * diff --git a/drivers/bus/vmbus/rte_bus_vmbus_version.map b/drivers/bus/vmbus/rte_bus_vmbus_version.map index dabb920310..ae231ad329 100644 --- a/drivers/bus/vmbus/rte_bus_vmbus_version.map +++ b/drivers/bus/vmbus/rte_bus_vmbus_version.map @@ -27,3 +27,10 @@ DPDK_18.08 { local: *; }; + +DPDK_18.11 { + global: + + rte_vmbus_set_latency; + +} DPDK_18.08; diff --git a/drivers/bus/vmbus/vmbus_channel.c b/drivers/bus/vmbus/vmbus_channel.c index cc5f3e8379..bd14c0662b 100644 --- a/drivers/bus/vmbus/vmbus_channel.c +++ b/drivers/bus/vmbus/vmbus_channel.c @@ -59,6 +59,32 @@ vmbus_set_event(const struct rte_vmbus_device *dev, vmbus_set_monitor(dev, chan->monitor_id); } +/* + * Set the wait between when hypervisor examines the trigger. + */ +void +rte_vmbus_set_latency(const struct rte_vmbus_device *dev, + const struct vmbus_channel *chan, + uint32_t latency) +{ + uint32_t trig_idx = chan->monitor_id / VMBUS_MONTRIG_LEN; + uint32_t trig_offs = chan->monitor_id % VMBUS_MONTRIG_LEN; + + if (latency >= UINT16_MAX * 100) { + VMBUS_LOG(ERR, "invalid latency value %u", latency); + return; + } + + if (trig_idx >= VMBUS_MONTRIGS_MAX) { + VMBUS_LOG(ERR, "invalid monitor trigger %u", + trig_idx); + return; + } + + /* Host value is expressed in 100 nanosecond units */ + dev->monitor_page->lat[trig_idx][trig_offs] = latency / 100; +} + /* * Notify host that there are data pending on our TX bufring. * -- 2.20.1