net/hyperv: Add flow control based on hi/low watermark
Subsystems (3)
Haiyang Zhang
maintainerv3 cover net/hyperv: Add flow control based on hi/low watermark
This patch is targeting 'net-next' tree (when re-opened).
Haiyang Zhang (1):
net/hyperv: Add flow control based on hi/low watermark
drivers/hv/ring_buffer.c | 31 ----------------------------- drivers/net/hyperv/netvsc.c | 41 +++++++++++++++++++++++++++++++++++--- drivers/net/hyperv/netvsc_drv.c | 6 ++++- include/linux/hyperv.h | 27 +++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 36 deletions(-)
Signature · 1 line
1.7.4.1
Haiyang Zhang
maintainerPATCH v3 1/1 net/hyperv: Add flow control based on hi/low watermark
In the existing code, we only stop queue when the ringbuffer is full, so the current packet has to be dropped or retried from upper layer.
This patch stops the tx queue when available ringbuffer is below the low watermark. So the ringbuffer still has small amount of space available for the current packet. This will reduce the overhead of retries on sending.
--- drivers/hv/ring_buffer.c | 31 ----------------------------- drivers/net/hyperv/netvsc.c | 41 +++++++++++++++++++++++++++++++++++--- drivers/net/hyperv/netvsc_drv.c | 6 ++++- include/linux/hyperv.h | 27 +++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 36 deletions(-)
drivers/hv/ring_buffer.c +0 -31
@@ -30,37 +30,6 @@#include "hyperv_vmbus.h" -/* #defines */ - - -/* Amount of space to write to */ -#define BYTES_AVAIL_TO_WRITE (r, w, z) \ - ((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w)) - - -/* -* -* hv_get_ringbuffer_availbytes() -* -* Get number of bytes available to read and to write to -* for the specified ring buffer -*/ -static inline void -hv_get_ringbuffer_availbytes (struct hv_ring_buffer_info *rbi, -u32 *read,u32 *write) -{ -u32 read_loc, write_loc; - -smp_read_barrier_depends (); - -/* Capture the read/write indices before they changed */ - read_loc = rbi->ring_buffer->read_index; - write_loc = rbi->ring_buffer->write_index; - - *write =BYTES_AVAIL_TO_WRITE (read_loc, write_loc, rbi->ring_datasize); - *read = rbi->ring_datasize - *write; -} -/* * hv_get_next_write_location() *
drivers/net/hyperv/netvsc.c +37 -4
69 lines not on this page · raw message
drivers/net/hyperv/netvsc_drv.c +5 -1
@@ -224,9 +224,13 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) net->stats.tx_packets++; }else {kfree (packet); +if (ret != -EAGAIN ) { +dev_kfree_skb_any (skb); + net->stats.tx_dropped++; + } } -return ret ?NETDEV_TX_BUSY :NETDEV_TX_OK ; +return (ret == -EAGAIN ) ?NETDEV_TX_BUSY :NETDEV_TX_OK ; }/*
include/linux/hyperv.h +27 -0
@@ -274,6 +274,33 @@ struct hv_ring_buffer_debug_info {u32 bytes_avail_towrite; }; + +/* +* +* hv_get_ringbuffer_availbytes() +* +* Get number of bytes available to read and to write to +* for the specified ring buffer +*/ +static inline void +hv_get_ringbuffer_availbytes (struct hv_ring_buffer_info *rbi, +u32 *read,u32 *write) +{ +u32 read_loc, write_loc, dsize; + +smp_read_barrier_depends (); + +/* Capture the read/write indices before they changed */ + read_loc = rbi->ring_buffer->read_index; + write_loc = rbi->ring_buffer->write_index; + dsize = rbi->ring_datasize; + + *write = write_loc >= read_loc ? dsize - (write_loc - read_loc) : + read_loc - write_loc; + *read = dsize - *write; +} + +/* * We use the same version numbering for all Hyper-V modules. *
Signature · 1 line
1.7.4.1
From: Haiyang Zhang <[email protected]>
Date: Tue, 27 Mar 2012 16:20:45 -0700
Quoted 10 lines
In the existing code, we only stop queue when the ringbuffer is full, so the current packet has to be dropped or retried from upper layer.
This patch stops the tx queue when available ringbuffer is below the low watermark. So the ringbuffer still has small amount of space available for the current packet. This will reduce the overhead of retries on sending.
Signed-off-by Haiyang Zhang <[email protected]>Reviewed-by K. Y. Srinivasan <[email protected]>
Applied to net-next