diff options
author | Haiyang Zhang <haiyangz@microsoft.com> | 2012-03-27 15:20:45 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-04-03 23:47:15 +0200 |
commit | 33be96e47cc27f2f1a753a0707b02a73df8c8d46 (patch) | |
tree | 2b0361f4d39a14e2ddd0d23e66656e6174b3cb71 /include | |
parent | sky2: fix missing register reset on error path in sky2_test_msi() (diff) | |
download | linux-33be96e47cc27f2f1a753a0707b02a73df8c8d46.tar.xz linux-33be96e47cc27f2f1a753a0707b02a73df8c8d46.zip |
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.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/hyperv.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 5852545e6bba..6af8738ae7e9 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -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. * |