Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 91e057c in mainline


Ignore:
Timestamp:
2014-06-23T22:24:46Z (6 years ago)
Author:
Agnieszka Tabaka <nufcia@…>
Branches:
master
Children:
727e639
Parents:
5a78e4e
Message:

Fixed ownership bit setting in TX interrupt handler, removed some
unneeded debug messages and reworked interrupt handling to (hopefully)
not miss any interrupts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/rtl8169/driver.c

    r5a78e4e r91e057c  
    237237
    238238        /* Allocate TX ring */
     239        rtl8169->tx_ring = AS_AREA_ANY;
    239240        rc = dmamem_map_anonymous(TX_RING_SIZE, DMAMEM_4GiB,
    240241            AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->tx_ring_phys,
     
    244245                return rc;
    245246
     247        ddf_msg(LVL_DEBUG, "TX ring address: phys=0x%08lx, virt=%p",
     248            rtl8169->tx_ring_phys, rtl8169->tx_ring);
     249
    246250        memset(rtl8169->tx_ring, 0, TX_RING_SIZE);
    247251
    248252        /* Allocate RX ring */
     253        rtl8169->rx_ring = AS_AREA_ANY;
    249254        rc = dmamem_map_anonymous(RX_RING_SIZE, DMAMEM_4GiB,
    250255            AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->rx_ring_phys,
     
    254259                return rc;
    255260
     261        ddf_msg(LVL_DEBUG, "RX ring address: phys=0x%08lx, virt=%p",
     262            rtl8169->rx_ring_phys, rtl8169->rx_ring);
     263
    256264        memset(rtl8169->rx_ring, 0, RX_RING_SIZE);
    257265
    258266        /* Allocate TX buffers */
     267        rtl8169->tx_buff = AS_AREA_ANY;
    259268        rc = dmamem_map_anonymous(TX_BUFFERS_SIZE, DMAMEM_4GiB,
    260269            AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->tx_buff_phys,
     
    264273                return rc;
    265274
     275        ddf_msg(LVL_DEBUG, "TX buffers base address: phys=0x%08lx, virt=%p",
     276            rtl8169->tx_buff_phys, rtl8169->tx_buff);
     277
    266278        /* Allocate RX buffers */
     279        rtl8169->rx_buff = AS_AREA_ANY;
    267280        rc = dmamem_map_anonymous(RX_BUFFERS_SIZE, DMAMEM_4GiB,
    268281            AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->rx_buff_phys,
     
    271284        if (rc != EOK)
    272285                return rc;
     286
     287        ddf_msg(LVL_DEBUG, "RX buffers base address: phys=0x%08lx, virt=%p",
     288            rtl8169->rx_buff_phys, rtl8169->rx_buff);
    273289
    274290        return EOK;
     
    556572static int rtl8169_on_activated(nic_t *nic_data)
    557573{
     574        int rc;
     575
    558576        ddf_msg(LVL_NOTE, "Activating device");
    559577
     
    565583
    566584        /* Allocate buffers */
    567         rtl8169_allocate_buffers(rtl8169);
     585        rc = rtl8169_allocate_buffers(rtl8169);
     586        if (rc != EOK) {
     587                ddf_msg(LVL_ERROR, "Error allocating buffers: %d", rc);
     588                return 0;
     589        }
    568590
    569591        /* Initialize RX ring */
     
    688710        while (tail != head) {
    689711                descr = &rtl8169->tx_ring[tail];
    690                 descr->control |= CONTROL_OWN;
     712                descr->control &= (~CONTROL_OWN);
     713                write_barrier();
    691714                ddf_msg(LVL_NOTE, "TX status for descr %d: 0x%08x", tail, descr->control);
    692 
     715       
    693716                tail = (tail + 1) % TX_BUFFERS_COUNT;
    694717        }
     
    769792
    770793        ddf_msg(LVL_NOTE, "rtl8169_irq_handler(): isr=0x%04x", isr);
     794        pio_write_16(rtl8169->regs + IMR, 0xffff);
    771795
    772796        while (isr != 0) {
     797                ddf_msg(LVL_DEBUG, "irq handler: remaining isr=0x%04x", isr);
     798
    773799                /* Packet underrun or link change */
    774800                if (isr & INT_PUN) {
     
    796822        }
    797823
    798         pio_write_16(rtl8169->regs + IMR, 0xffff);
    799824        pio_write_16(rtl8169->regs + ISR, 0xffff);
    800825}
     
    816841        fibril_mutex_lock(&rtl8169->tx_lock);
    817842
    818         ddf_msg(LVL_NOTE, "send_frame()");
    819         ddf_msg(LVL_NOTE, "size: %ld", size);
    820         ddf_msg(LVL_NOTE, "tx ring virtual at %p", rtl8169->tx_ring);
    821         ddf_msg(LVL_NOTE, "tx_head=%d tx_tail=%d", rtl8169->tx_head, rtl8169->tx_tail);
     843        ddf_msg(LVL_NOTE, "send_frame: size: %ld, tx_head=%d tx_tail=%d",
     844            size, rtl8169->tx_head, rtl8169->tx_tail);
    822845
    823846        head = rtl8169->tx_head;
     
    854877        rtl8169->tx_head = (head + 1) % TX_BUFFERS_COUNT;
    855878
     879        ddf_msg(LVL_DEBUG, "control: 0x%08x", descr->control);
     880
    856881        write_barrier();
    857882
     
    859884        pio_write_8(rtl8169->regs + TPPOLL, TPPOLL_NPQ);
    860885        write_barrier();
    861 
    862         ddf_msg(LVL_NOTE, "triggered TPPOLL");
    863886
    864887        fibril_mutex_unlock(&rtl8169->tx_lock);
Note: See TracChangeset for help on using the changeset viewer.