[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 3/5] hw/net/stellaris_enet: Rewrite tx fifo hand
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH 3/5] hw/net/stellaris_enet: Rewrite tx fifo handling code |
Date: |
Tue, 1 Apr 2014 18:29:27 +0100 |
On 1 April 2014 18:26, Dr. David Alan Gilbert <address@hidden> wrote:
> * Peter Maydell (address@hidden) wrote:
>> The datasheet is clear that the frame length written to the DATA
>> register is actually stored in the TX FIFO; this means we don't
>> need to keep both tx_frame_len and tx_fifo_len state separately.
>>
>> Signed-off-by: Peter Maydell <address@hidden>
>> ---
>> hw/net/stellaris_enet.c | 119
>> +++++++++++++++++++++++++++++++-----------------
>> 1 file changed, 77 insertions(+), 42 deletions(-)
>>
>> diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
>> index d0da819..b99f93e 100644
>> --- a/hw/net/stellaris_enet.c
>> +++ b/hw/net/stellaris_enet.c
>> @@ -59,7 +59,6 @@ typedef struct {
>> uint32_t mtxd;
>> uint32_t mrxd;
>> uint32_t np;
>> - int tx_frame_len;
>> int tx_fifo_len;
>> uint8_t tx_fifo[2048];
>> /* Real hardware has a 2k fifo, which works out to be at most 31
>> packets.
>> @@ -82,6 +81,62 @@ static void stellaris_enet_update(stellaris_enet_state *s)
>> qemu_set_irq(s->irq, (s->ris & s->im) != 0);
>> }
>>
>> +/* Return the data length of the packet currently being assembled
>> + * in the TX fifo.
>> + */
>> +static inline int stellaris_txpacket_datalen(stellaris_enet_state *s)
>> +{
>> + return s->tx_fifo[0] | (s->tx_fifo[1] << 8);
>> +}
>> +
>> +/* Return true if the packet currently in the TX FIFO is complete,
>> +* ie the FIFO holds enough bytes for the data length, ethernet header,
>> +* payload and optionally CRC.
>> +*/
>> +static inline bool stellaris_txpacket_complete(stellaris_enet_state *s)
>> +{
>> + int framelen = stellaris_txpacket_datalen(s);
>> + framelen += 16;
>
> What's the magical 16? (It doesn't jump out from the data sheet).
See table 15-3: 2 bytes of data length, 6 bytes dest addr,
6 bytes source addr, 2 bytes len/type.
> You should probably increment the migration state version number to 2.
Oops, yes.
thanks
-- PMM
- Re: [Qemu-devel] [PATCH 5/5] hw/net/stellaris_enet: Fix debug format strings, (continued)
- [Qemu-devel] [PATCH 4/5] hw/net/stellaris_enet: Correctly implement the TR and THR registers, Peter Maydell, 2014/04/01
- [Qemu-devel] [PATCH 2/5] hw/net/stellaris_enet: Correct handling of packet padding, Peter Maydell, 2014/04/01
- [Qemu-devel] [PATCH 1/5] hw/net/stellaris_enet: Restructure tx_fifo code to avoid buffer overrun, Peter Maydell, 2014/04/01
- [Qemu-devel] [PATCH 3/5] hw/net/stellaris_enet: Rewrite tx fifo handling code, Peter Maydell, 2014/04/01
- Re: [Qemu-devel] [PATCH 3/5] hw/net/stellaris_enet: Rewrite tx fifo handling code, Dr. David Alan Gilbert, 2014/04/01
Re: [Qemu-devel] [PATCH 0/5] stellaris_enet: overhaul TX handling, Peter Maydell, 2014/04/01