Changeset 91e057c in mainline
- Timestamp:
- 2014-06-23T22:24:46Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 727e639
- Parents:
- 5a78e4e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/rtl8169/driver.c
r5a78e4e r91e057c 237 237 238 238 /* Allocate TX ring */ 239 rtl8169->tx_ring = AS_AREA_ANY; 239 240 rc = dmamem_map_anonymous(TX_RING_SIZE, DMAMEM_4GiB, 240 241 AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->tx_ring_phys, … … 244 245 return rc; 245 246 247 ddf_msg(LVL_DEBUG, "TX ring address: phys=0x%08lx, virt=%p", 248 rtl8169->tx_ring_phys, rtl8169->tx_ring); 249 246 250 memset(rtl8169->tx_ring, 0, TX_RING_SIZE); 247 251 248 252 /* Allocate RX ring */ 253 rtl8169->rx_ring = AS_AREA_ANY; 249 254 rc = dmamem_map_anonymous(RX_RING_SIZE, DMAMEM_4GiB, 250 255 AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->rx_ring_phys, … … 254 259 return rc; 255 260 261 ddf_msg(LVL_DEBUG, "RX ring address: phys=0x%08lx, virt=%p", 262 rtl8169->rx_ring_phys, rtl8169->rx_ring); 263 256 264 memset(rtl8169->rx_ring, 0, RX_RING_SIZE); 257 265 258 266 /* Allocate TX buffers */ 267 rtl8169->tx_buff = AS_AREA_ANY; 259 268 rc = dmamem_map_anonymous(TX_BUFFERS_SIZE, DMAMEM_4GiB, 260 269 AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->tx_buff_phys, … … 264 273 return rc; 265 274 275 ddf_msg(LVL_DEBUG, "TX buffers base address: phys=0x%08lx, virt=%p", 276 rtl8169->tx_buff_phys, rtl8169->tx_buff); 277 266 278 /* Allocate RX buffers */ 279 rtl8169->rx_buff = AS_AREA_ANY; 267 280 rc = dmamem_map_anonymous(RX_BUFFERS_SIZE, DMAMEM_4GiB, 268 281 AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->rx_buff_phys, … … 271 284 if (rc != EOK) 272 285 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); 273 289 274 290 return EOK; … … 556 572 static int rtl8169_on_activated(nic_t *nic_data) 557 573 { 574 int rc; 575 558 576 ddf_msg(LVL_NOTE, "Activating device"); 559 577 … … 565 583 566 584 /* 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 } 568 590 569 591 /* Initialize RX ring */ … … 688 710 while (tail != head) { 689 711 descr = &rtl8169->tx_ring[tail]; 690 descr->control |= CONTROL_OWN; 712 descr->control &= (~CONTROL_OWN); 713 write_barrier(); 691 714 ddf_msg(LVL_NOTE, "TX status for descr %d: 0x%08x", tail, descr->control); 692 715 693 716 tail = (tail + 1) % TX_BUFFERS_COUNT; 694 717 } … … 769 792 770 793 ddf_msg(LVL_NOTE, "rtl8169_irq_handler(): isr=0x%04x", isr); 794 pio_write_16(rtl8169->regs + IMR, 0xffff); 771 795 772 796 while (isr != 0) { 797 ddf_msg(LVL_DEBUG, "irq handler: remaining isr=0x%04x", isr); 798 773 799 /* Packet underrun or link change */ 774 800 if (isr & INT_PUN) { … … 796 822 } 797 823 798 pio_write_16(rtl8169->regs + IMR, 0xffff);799 824 pio_write_16(rtl8169->regs + ISR, 0xffff); 800 825 } … … 816 841 fibril_mutex_lock(&rtl8169->tx_lock); 817 842 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); 822 845 823 846 head = rtl8169->tx_head; … … 854 877 rtl8169->tx_head = (head + 1) % TX_BUFFERS_COUNT; 855 878 879 ddf_msg(LVL_DEBUG, "control: 0x%08x", descr->control); 880 856 881 write_barrier(); 857 882 … … 859 884 pio_write_8(rtl8169->regs + TPPOLL, TPPOLL_NPQ); 860 885 write_barrier(); 861 862 ddf_msg(LVL_NOTE, "triggered TPPOLL");863 886 864 887 fibril_mutex_unlock(&rtl8169->tx_lock);
Note:
See TracChangeset
for help on using the changeset viewer.