Commit bd49fea7 authored by Shachar Raindel's avatar Shachar Raindel Committed by David S. Miller

hv_netvsc: Add a comment clarifying batching logic

The batching logic in netvsc_send is non-trivial, due to
a combination of the Linux API and the underlying hypervisor
interface. Add a comment explaining why the code is written this
way.
Signed-off-by: default avatarShachar Raindel <shacharr@microsoft.com>
Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: default avatarDexuan Cui <decui@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0f88e6f3
...@@ -87,11 +87,15 @@ Receive Buffer ...@@ -87,11 +87,15 @@ Receive Buffer
contain one or more packets. The number of receive sections may be changed contain one or more packets. The number of receive sections may be changed
via ethtool Rx ring parameters. via ethtool Rx ring parameters.
There is a similar send buffer which is used to aggregate packets for sending. There is a similar send buffer which is used to aggregate packets
The send area is broken into chunks of 6144 bytes, each of section may for sending. The send area is broken into chunks, typically of 6144
contain one or more packets. The send buffer is an optimization, the driver bytes, each of section may contain one or more packets. Small
will use slower method to handle very large packets or if the send buffer packets are usually transmitted via copy to the send buffer. However,
area is exhausted. if the buffer is temporarily exhausted, or the packet to be transmitted is
an LSO packet, the driver will provide the host with pointers to the data
from the SKB. This attempts to achieve a balance between the overhead of
data copy and the impact of remapping VM memory to be accessible by the
host.
XDP support XDP support
----------- -----------
......
...@@ -1017,6 +1017,26 @@ static inline void move_pkt_msd(struct hv_netvsc_packet **msd_send, ...@@ -1017,6 +1017,26 @@ static inline void move_pkt_msd(struct hv_netvsc_packet **msd_send,
} }
/* RCU already held by caller */ /* RCU already held by caller */
/* Batching/bouncing logic is designed to attempt to optimize
* performance.
*
* For small, non-LSO packets we copy the packet to a send buffer
* which is pre-registered with the Hyper-V side. This enables the
* hypervisor to avoid remapping the aperture to access the packet
* descriptor and data.
*
* If we already started using a buffer and the netdev is transmitting
* a burst of packets, keep on copying into the buffer until it is
* full or we are done collecting a burst. If there is an existing
* buffer with space for the RNDIS descriptor but not the packet, copy
* the RNDIS descriptor to the buffer, keeping the packet in place.
*
* If we do batching and send more than one packet using a single
* NetVSC message, free the SKBs of the packets copied, except for the
* last packet. This is done to streamline the handling of the case
* where the last packet only had the RNDIS descriptor copied to the
* send buffer, with the data pointers included in the NetVSC message.
*/
int netvsc_send(struct net_device *ndev, int netvsc_send(struct net_device *ndev,
struct hv_netvsc_packet *packet, struct hv_netvsc_packet *packet,
struct rndis_message *rndis_msg, struct rndis_message *rndis_msg,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment