mirror of https://gitlab.com/qemu-project/qemu
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>
This commit is contained in:
parent
b6cb6610c2
commit
575bafd1f3
|
@ -342,13 +342,22 @@ static ssize_t etsec_receive(NetClientState *nc,
|
||||||
const uint8_t *buf,
|
const uint8_t *buf,
|
||||||
size_t size)
|
size_t size)
|
||||||
{
|
{
|
||||||
|
ssize_t ret;
|
||||||
eTSEC *etsec = qemu_get_nic_opaque(nc);
|
eTSEC *etsec = qemu_get_nic_opaque(nc);
|
||||||
|
|
||||||
#if defined(HEX_DUMP)
|
#if defined(HEX_DUMP)
|
||||||
fprintf(stderr, "%s receive size:%d\n", etsec->nic->nc.name, size);
|
fprintf(stderr, "%s receive size:%d\n", etsec->nic->nc.name, size);
|
||||||
qemu_hexdump(buf, stderr, "", size);
|
qemu_hexdump(buf, stderr, "", size);
|
||||||
#endif
|
#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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -144,6 +144,8 @@ typedef struct eTSEC {
|
||||||
QEMUBH *bh;
|
QEMUBH *bh;
|
||||||
struct ptimer_state *ptimer;
|
struct ptimer_state *ptimer;
|
||||||
|
|
||||||
|
/* Whether we should flush the rx queue when buffer becomes available. */
|
||||||
|
bool need_flush;
|
||||||
} eTSEC;
|
} eTSEC;
|
||||||
|
|
||||||
#define TYPE_ETSEC_COMMON "eTSEC"
|
#define TYPE_ETSEC_COMMON "eTSEC"
|
||||||
|
|
|
@ -646,6 +646,9 @@ void etsec_walk_rx_ring(eTSEC *etsec, int ring_nbr)
|
||||||
} else {
|
} else {
|
||||||
etsec->rx_buffer_len = 0;
|
etsec->rx_buffer_len = 0;
|
||||||
etsec->rx_buffer = NULL;
|
etsec->rx_buffer = NULL;
|
||||||
|
if (etsec->need_flush) {
|
||||||
|
qemu_flush_queued_packets(qemu_get_queue(etsec->nic));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RING_DEBUG("eTSEC End of ring_write: remaining_data:%zu\n", remaining_data);
|
RING_DEBUG("eTSEC End of ring_write: remaining_data:%zu\n", remaining_data);
|
||||||
|
|
Loading…
Reference in New Issue