[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170503230117.20070-6-sthemmin@microsoft.com>
Date: Wed, 3 May 2017 16:01:07 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org, Stephen Hemminger <sthemmin@...rosoft.com>
Subject: [PATCH net-next 05/15] netvsc: optimize avail percent calculation
Only need to look at write space (not read space) when computing
percent available.
Signed-off-by: Stephen Hemminger <sthemmin@...rosoft.com>
---
drivers/net/hyperv/netvsc.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 385809512c9f..ee5f8c520977 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -598,14 +598,13 @@ void netvsc_device_remove(struct hv_device *device)
* Get the percentage of available bytes to write in the ring.
* The return value is in range from 0 to 100.
*/
-static inline u32 hv_ringbuf_avail_percent(
- struct hv_ring_buffer_info *ring_info)
+static inline
+u32 hv_ringbuf_avail_percent(const struct vmbus_channel *channel)
{
- u32 avail_read, avail_write;
+ const struct hv_ring_buffer_info *ring_info = &channel->outbound;
+ u32 avail_write = hv_get_bytes_to_write(ring_info);
- hv_get_ringbuffer_availbytes(ring_info, &avail_read, &avail_write);
-
- return avail_write * 100 / ring_info->ring_datasize;
+ return (avail_write * 100) / ring_info->ring_datasize;
}
static inline void netvsc_free_send_slot(struct netvsc_device *net_device,
@@ -655,7 +654,7 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device,
wake_up(&net_device->wait_drain);
if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx)) &&
- (hv_ringbuf_avail_percent(&channel->outbound) > RING_AVAIL_PERCENT_HIWATER ||
+ (hv_ringbuf_avail_percent(channel) > RING_AVAIL_PERCENT_HIWATER ||
queue_sends < 1))
netif_tx_wake_queue(netdev_get_tx_queue(ndev, q_idx));
}
@@ -764,7 +763,7 @@ static inline int netvsc_send_pkt(
u64 req_id;
int ret;
struct hv_page_buffer *pgbuf;
- u32 ring_avail = hv_ringbuf_avail_percent(&out_channel->outbound);
+ u32 ring_avail = hv_ringbuf_avail_percent(out_channel);
nvmsg.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT;
if (skb != NULL) {
--
2.11.0
Powered by blists - more mailing lists