Revision 6e50d188 hw/net/opencores_eth.c

b/hw/net/opencores_eth.c
169 169
};
170 170

  
171 171
enum {
172
    INT_SOURCE_BUSY = 0x10,
172 173
    INT_SOURCE_RXB = 0x4,
173 174
    INT_SOURCE_TXB = 0x1,
174 175
};
......
351 352
    OpenEthState *s = qemu_get_nic_opaque(nc);
352 353

  
353 354
    return GET_REGBIT(s, MODER, RXEN) &&
354
        (s->regs[TX_BD_NUM] < 0x80) &&
355
        (rx_desc(s)->len_flags & RXD_E);
355
        (s->regs[TX_BD_NUM] < 0x80);
356 356
}
357 357

  
358 358
static ssize_t open_eth_receive(NetClientState *nc,
......
402 402
        desc *desc = rx_desc(s);
403 403
        size_t copy_size = GET_REGBIT(s, MODER, HUGEN) ? 65536 : maxfl;
404 404

  
405
        if (!(desc->len_flags & RXD_E)) {
406
            open_eth_int_source_write(s,
407
                    s->regs[INT_SOURCE] | INT_SOURCE_BUSY);
408
            return size;
409
        }
410

  
405 411
        desc->len_flags &= ~(RXD_CF | RXD_M | RXD_OR |
406 412
                RXD_IS | RXD_DN | RXD_TL | RXD_SF | RXD_CRC | RXD_LC);
407 413

  
......
551 557
    return v;
552 558
}
553 559

  
560
static void open_eth_notify_can_receive(OpenEthState *s)
561
{
562
    NetClientState *nc = qemu_get_queue(s->nic);
563

  
564
    if (open_eth_can_receive(nc)) {
565
        qemu_flush_queued_packets(nc);
566
    }
567
}
568

  
554 569
static void open_eth_ro(OpenEthState *s, uint32_t val)
555 570
{
556 571
}
......
567 582

  
568 583
    if (set & MODER_RXEN) {
569 584
        s->rx_desc = s->regs[TX_BD_NUM];
585
        open_eth_notify_can_receive(s);
570 586
    }
571 587
    if (set & MODER_TXEN) {
572 588
        s->tx_desc = 0;
......
592 608
            s->regs[INT_SOURCE] & s->regs[INT_MASK]);
593 609
}
594 610

  
611
static void open_eth_tx_bd_num_host_write(OpenEthState *s, uint32_t val)
612
{
613
    if (val < 0x80) {
614
        bool enable = s->regs[TX_BD_NUM] == 0x80;
615

  
616
        s->regs[TX_BD_NUM] = val;
617
        if (enable) {
618
            open_eth_notify_can_receive(s);
619
        }
620
    }
621
}
622

  
595 623
static void open_eth_mii_command_host_write(OpenEthState *s, uint32_t val)
596 624
{
597 625
    unsigned fiad = GET_REGFIELD(s, MIIADDRESS, FIAD);
......
630 658
        [MODER] = open_eth_moder_host_write,
631 659
        [INT_SOURCE] = open_eth_int_source_host_write,
632 660
        [INT_MASK] = open_eth_int_mask_host_write,
661
        [TX_BD_NUM] = open_eth_tx_bd_num_host_write,
633 662
        [MIICOMMAND] = open_eth_mii_command_host_write,
634 663
        [MIITX_DATA] = open_eth_mii_tx_host_write,
635 664
        [MIISTATUS] = open_eth_ro,

Also available in: Unified diff