stream: Add flow control API

Add basic flow control to stream. A stream slave may return short, indicating
that it is not capable of accepting any more data at the present time. Polling
or a callback can be used via the can_push() function to determine when the
slave can receive again.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
This commit is contained in:
Peter Crosthwaite 2013-04-16 10:27:16 +10:00 committed by Edgar E. Iglesias
parent 210914e299
commit 35e60bfdbc
4 changed files with 48 additions and 9 deletions

View file

@ -815,7 +815,7 @@ static void eth_cleanup(NetClientState *nc)
g_free(s);
}
static void
static size_t
xilinx_axienet_data_stream_push(StreamSlave *obj, uint8_t *buf, size_t size,
uint32_t *hdr)
{
@ -824,13 +824,13 @@ xilinx_axienet_data_stream_push(StreamSlave *obj, uint8_t *buf, size_t size,
/* TX enable ? */
if (!(s->tc & TC_TX)) {
return;
return size;
}
/* Jumbo or vlan sizes ? */
if (!(s->tc & TC_JUM)) {
if (size > 1518 && size <= 1522 && !(s->tc & TC_VLAN)) {
return;
return size;
}
}
@ -858,6 +858,8 @@ xilinx_axienet_data_stream_push(StreamSlave *obj, uint8_t *buf, size_t size,
s->stats.tx_bytes += size;
s->regs[R_IS] |= IS_TX_COMPLETE;
enet_update_irq(s);
return size;
}
static NetClientInfo net_xilinx_enet_info = {