net/hyperv: Add flow control based on hi/low watermark
Subsystems (3)
Haiyang Zhang
maintainercover 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 | 29 +++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 36 deletions(-)
Signature · 1 line
1.7.4.1
Haiyang Zhang
maintainerPATCH 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 | 29 +++++++++++++++++++++++++++ 4 files changed, 71 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 +29 -0
@@ -274,6 +274,35 @@ struct hv_ring_buffer_debug_info {u32 bytes_avail_towrite; }; +/* 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 +*/ +extern 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; +} + +/* * We use the same version numbering for all Hyper-V modules. *
Signature · 1 line
1.7.4.1
include/linux/hyperv.h struct hv_ring_buffer_debug_info { · line 280
Quoted 10 lines · Haiyang Zhang
include/linux/hyperv.h +4
-0@@ -274,6 +274,35 @@ struct hv_ring_buffer_debug_info {u32 bytes_avail_towrite; }; +/* Amount of space to write to */ +#define BYTES_AVAIL_TO_WRITE (r, w, z) \ + (((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w))) +
That's a very bad #define to use in a .h file, please do not do that.
include/linux/hyperv.h struct hv_ring_buffer_debug_info { · line 291
Quoted 11 lines
include/linux/hyperv.h +11
-0+ +/* +* +* hv_get_ringbuffer_availbytes() +* +* Get number of bytes available to read and to write to +* for the specified ring buffer +*/ +extern inline void +hv_get_ringbuffer_availbytes (struct hv_ring_buffer_info *rbi, +u32 *read,u32 *write)
What does "extern inline" mean?
Please fix.
greg k-h
Haiyang Zhang
maintainerQuoted 39 lines
-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Tuesday, March 27, 2012 6:21 PM
To: Haiyang Zhang
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/1] net/hyperv: Add flow control based on hi/low watermarkinclude/linux/hyperv.h struct hv_ring_buffer_debug_info { · line 280
Quoted 10 lines · Haiyang Zhang
include/linux/hyperv.h +4
-0@@ -274,6 +274,35 @@ struct hv_ring_buffer_debug_info {u32 bytes_avail_towrite; }; +/* Amount of space to write to */ +#define BYTES_AVAIL_TO_WRITE (r, w, z) \ + (((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w))) +That's a very bad #define to use in a .h file, please do not do that.
include/linux/hyperv.h struct hv_ring_buffer_debug_info { · line 291
Quoted 11 lines
include/linux/hyperv.h +11
-0+ +/* +* +* hv_get_ringbuffer_availbytes() +* +* Get number of bytes available to read and to write to +* for the specified ring buffer +*/ +extern inline void +hv_get_ringbuffer_availbytes (struct hv_ring_buffer_info *rbi, +u32 *read,u32 *write)What does "extern inline" mean?
Quoted 1 line
Please fix.
Will do.
Thanks,
- Haiyang