diff options
author | Fam Zheng <famz@redhat.com> | 2015-07-15 18:19:07 +0800 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2015-07-27 14:12:18 +0100 |
commit | 575bafd1f387c5f06b59cf2515f6bb1eff9d119d (patch) | |
tree | dae0ac3fefb0012d3eba9370944b44dd58ad8bc9 /hw/net/fsl_etsec/etsec.c | |
parent | b6cb6610c27c5b0773a340499f19c3477bf45aeb (diff) |
etsec: Flush queue when rx buffer is consumed
The BH will be scheduled when etsec->rx_buffer_len is becoming 0, which
is the condition of queuing.
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1436955553-22791-7-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'hw/net/fsl_etsec/etsec.c')
-rw-r--r-- | hw/net/fsl_etsec/etsec.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c index f5170aee86..0f5cf4477b 100644 --- a/hw/net/fsl_etsec/etsec.c +++ b/hw/net/fsl_etsec/etsec.c @@ -342,13 +342,22 @@ static ssize_t etsec_receive(NetClientState *nc, const uint8_t *buf, size_t size) { + ssize_t ret; eTSEC *etsec = qemu_get_nic_opaque(nc); #if defined(HEX_DUMP) fprintf(stderr, "%s receive size:%d\n", etsec->nic->nc.name, size); qemu_hexdump(buf, stderr, "", size); #endif - return etsec_rx_ring_write(etsec, buf, size); + /* Flush is unnecessary as are already in receiving path */ + etsec->need_flush = false; + ret = etsec_rx_ring_write(etsec, buf, size); + if (ret == 0) { + /* The packet will be queued, let's flush it when buffer is avilable + * again. */ + etsec->need_flush = true; + } + return ret; } |