diff mbox

[RFC,v6,3/3] virtio-net rsc: add 2 new rsc information fields to 'virtio_net_hdr'

Message ID 1464453454-5703-4-git-send-email-wexu@redhat.com
State New
Headers show

Commit Message

Wei Xu May 28, 2016, 4:37 p.m. UTC
From: Wei Xu <wexu@redhat.com>

Field 'coalesced' is to indicate how many packets are coalesced and field
'dup_ack' is how many duplicate acks are merged, guest driver can use these
information to notify what's the exact scene of original traffic over the
networks.

Signed-off-by: Wei Xu <wexu@redhat.com>
---
 hw/net/virtio-net.c                         | 8 ++++++++
 include/standard-headers/linux/virtio_net.h | 2 ++
 2 files changed, 10 insertions(+)

Comments

Jason Wang May 30, 2016, 5:57 a.m. UTC | #1
On 2016年05月29日 00:37, wexu@redhat.com wrote:
> From: Wei Xu <wexu@redhat.com>
>
> Field 'coalesced' is to indicate how many packets are coalesced and field
> 'dup_ack' is how many duplicate acks are merged, guest driver can use these
> information to notify what's the exact scene of original traffic over the
> networks.
>
> Signed-off-by: Wei Xu <wexu@redhat.com>
> ---
>   hw/net/virtio-net.c                         | 8 ++++++++
>   include/standard-headers/linux/virtio_net.h | 2 ++
>   2 files changed, 10 insertions(+)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index cc8cbe4..20f552a 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -1768,6 +1768,10 @@ static size_t virtio_net_rsc_drain_seg(NetRscChain *chain, NetRscSeg *seg)
>       if ((chain->proto == ETH_P_IP) && seg->is_coalesced) {
>           virtio_net_rsc_ipv4_checksum(h, seg->unit.ip);
>       }
> +    h->coalesced = seg->packets;
> +    h->dup_ack = seg->dup_ack;
> +    h->gso_type = chain->gso_type;
> +    h->gso_size = chain->max_payload;
>       ret = virtio_net_do_receive(seg->nc, seg->buf, seg->size);
>       QTAILQ_REMOVE(&chain->buffers, seg, next);
>       g_free(seg->buf);
> @@ -2302,9 +2306,13 @@ static ssize_t virtio_net_receive(NetClientState *nc,
>                                     const uint8_t *buf, size_t size)
>   {
>       VirtIONet *n;
> +    struct virtio_net_hdr *h;
>   
>       n = qemu_get_nic_opaque(nc);
>       if (n->host_features & (1ULL << VIRTIO_NET_F_GUEST_RSC)) {
> +        h = (struct virtio_net_hdr *)buf;
> +        h->coalesced = 0;
> +        h->dup_ack = 0;
>           return virtio_net_rsc_receive(nc, buf, size);
>       } else {
>           return virtio_net_do_receive(nc, buf, size);
> diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard-headers/linux/virtio_net.h
> index 5b95762..c837417 100644
> --- a/include/standard-headers/linux/virtio_net.h
> +++ b/include/standard-headers/linux/virtio_net.h
> @@ -114,6 +114,8 @@ struct virtio_net_hdr {
>   	__virtio16 gso_size;		/* Bytes to append to hdr_len per frame */
>   	__virtio16 csum_start;	/* Position to start checksumming from */
>   	__virtio16 csum_offset;	/* Offset after that to place checksum */
> +    __virtio16 coalesced;   /* packets coalesced by host */

Can we just reuse gso_segs for this?

> +    __virtio16 dup_ack;     /* duplicate ack count */
>   };
>   
>   /* This is the version of the header to use when the MRG_RXBUF
Wei Xu June 2, 2016, 4:23 p.m. UTC | #2
On 2016年05月30日 13:57, Jason Wang wrote:
>
>
> On 2016年05月29日 00:37, wexu@redhat.com wrote:
>> From: Wei Xu <wexu@redhat.com>
>>
>> Field 'coalesced' is to indicate how many packets are coalesced and field
>> 'dup_ack' is how many duplicate acks are merged, guest driver can use
>> these
>> information to notify what's the exact scene of original traffic over the
>> networks.
>>
>> Signed-off-by: Wei Xu <wexu@redhat.com>
>> ---
>>   hw/net/virtio-net.c                         | 8 ++++++++
>>   include/standard-headers/linux/virtio_net.h | 2 ++
>>   2 files changed, 10 insertions(+)
>>
>> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
>> index cc8cbe4..20f552a 100644
>> --- a/hw/net/virtio-net.c
>> +++ b/hw/net/virtio-net.c
>> @@ -1768,6 +1768,10 @@ static size_t
>> virtio_net_rsc_drain_seg(NetRscChain *chain, NetRscSeg *seg)
>>       if ((chain->proto == ETH_P_IP) && seg->is_coalesced) {
>>           virtio_net_rsc_ipv4_checksum(h, seg->unit.ip);
>>       }
>> +    h->coalesced = seg->packets;
>> +    h->dup_ack = seg->dup_ack;
>> +    h->gso_type = chain->gso_type;
>> +    h->gso_size = chain->max_payload;
>>       ret = virtio_net_do_receive(seg->nc, seg->buf, seg->size);
>>       QTAILQ_REMOVE(&chain->buffers, seg, next);
>>       g_free(seg->buf);
>> @@ -2302,9 +2306,13 @@ static ssize_t
>> virtio_net_receive(NetClientState *nc,
>>                                     const uint8_t *buf, size_t size)
>>   {
>>       VirtIONet *n;
>> +    struct virtio_net_hdr *h;
>>       n = qemu_get_nic_opaque(nc);
>>       if (n->host_features & (1ULL << VIRTIO_NET_F_GUEST_RSC)) {
>> +        h = (struct virtio_net_hdr *)buf;
>> +        h->coalesced = 0;
>> +        h->dup_ack = 0;
>>           return virtio_net_rsc_receive(nc, buf, size);
>>       } else {
>>           return virtio_net_do_receive(nc, buf, size);
>> diff --git a/include/standard-headers/linux/virtio_net.h
>> b/include/standard-headers/linux/virtio_net.h
>> index 5b95762..c837417 100644
>> --- a/include/standard-headers/linux/virtio_net.h
>> +++ b/include/standard-headers/linux/virtio_net.h
>> @@ -114,6 +114,8 @@ struct virtio_net_hdr {
>>       __virtio16 gso_size;        /* Bytes to append to hdr_len per
>> frame */
>>       __virtio16 csum_start;    /* Position to start checksumming from */
>>       __virtio16 csum_offset;    /* Offset after that to place
>> checksum */
>> +    __virtio16 coalesced;   /* packets coalesced by host */
>
> Can we just reuse gso_segs for this?
That's really a good idea, in particular, if we can multiplex the 
capability field and header fields, then i'm supposing we don't need 
change the spec, this feature may work if we don't coalesce any 
'dup_ack' packet due to my latest test.
>
>> +    __virtio16 dup_ack;     /* duplicate ack count */
>>   };
>>   /* This is the version of the header to use when the MRG_RXBUF
>
diff mbox

Patch

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index cc8cbe4..20f552a 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1768,6 +1768,10 @@  static size_t virtio_net_rsc_drain_seg(NetRscChain *chain, NetRscSeg *seg)
     if ((chain->proto == ETH_P_IP) && seg->is_coalesced) {
         virtio_net_rsc_ipv4_checksum(h, seg->unit.ip);
     }
+    h->coalesced = seg->packets;
+    h->dup_ack = seg->dup_ack;
+    h->gso_type = chain->gso_type;
+    h->gso_size = chain->max_payload;
     ret = virtio_net_do_receive(seg->nc, seg->buf, seg->size);
     QTAILQ_REMOVE(&chain->buffers, seg, next);
     g_free(seg->buf);
@@ -2302,9 +2306,13 @@  static ssize_t virtio_net_receive(NetClientState *nc,
                                   const uint8_t *buf, size_t size)
 {
     VirtIONet *n;
+    struct virtio_net_hdr *h;
 
     n = qemu_get_nic_opaque(nc);
     if (n->host_features & (1ULL << VIRTIO_NET_F_GUEST_RSC)) {
+        h = (struct virtio_net_hdr *)buf;
+        h->coalesced = 0;
+        h->dup_ack = 0;
         return virtio_net_rsc_receive(nc, buf, size);
     } else {
         return virtio_net_do_receive(nc, buf, size);
diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard-headers/linux/virtio_net.h
index 5b95762..c837417 100644
--- a/include/standard-headers/linux/virtio_net.h
+++ b/include/standard-headers/linux/virtio_net.h
@@ -114,6 +114,8 @@  struct virtio_net_hdr {
 	__virtio16 gso_size;		/* Bytes to append to hdr_len per frame */
 	__virtio16 csum_start;	/* Position to start checksumming from */
 	__virtio16 csum_offset;	/* Offset after that to place checksum */
+    __virtio16 coalesced;   /* packets coalesced by host */
+    __virtio16 dup_ack;     /* duplicate ack count */
 };
 
 /* This is the version of the header to use when the MRG_RXBUF