Index: uspace/drv/nic/rtl8169/driver.c
===================================================================
--- uspace/drv/nic/rtl8169/driver.c	(revision 5a78e4e14737d21e189bc1614c66a235668d3de0)
+++ uspace/drv/nic/rtl8169/driver.c	(revision 91e057c6b2bdaac372a47885481f6c956b863278)
@@ -237,4 +237,5 @@
 
 	/* Allocate TX ring */
+	rtl8169->tx_ring = AS_AREA_ANY;
 	rc = dmamem_map_anonymous(TX_RING_SIZE, DMAMEM_4GiB, 
 	    AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->tx_ring_phys,
@@ -244,7 +245,11 @@
 		return rc;
 
+	ddf_msg(LVL_DEBUG, "TX ring address: phys=0x%08lx, virt=%p",
+	    rtl8169->tx_ring_phys, rtl8169->tx_ring);
+
 	memset(rtl8169->tx_ring, 0, TX_RING_SIZE);
 
 	/* Allocate RX ring */
+	rtl8169->rx_ring = AS_AREA_ANY;
 	rc = dmamem_map_anonymous(RX_RING_SIZE, DMAMEM_4GiB, 
 	    AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->rx_ring_phys,
@@ -254,7 +259,11 @@
 		return rc;
 
+	ddf_msg(LVL_DEBUG, "RX ring address: phys=0x%08lx, virt=%p",
+	    rtl8169->rx_ring_phys, rtl8169->rx_ring);
+
 	memset(rtl8169->rx_ring, 0, RX_RING_SIZE);
 
 	/* Allocate TX buffers */
+	rtl8169->tx_buff = AS_AREA_ANY;
 	rc = dmamem_map_anonymous(TX_BUFFERS_SIZE, DMAMEM_4GiB, 
 	    AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->tx_buff_phys,
@@ -264,5 +273,9 @@
 		return rc;
 
+	ddf_msg(LVL_DEBUG, "TX buffers base address: phys=0x%08lx, virt=%p",
+	    rtl8169->tx_buff_phys, rtl8169->tx_buff);
+
 	/* Allocate RX buffers */
+	rtl8169->rx_buff = AS_AREA_ANY;
 	rc = dmamem_map_anonymous(RX_BUFFERS_SIZE, DMAMEM_4GiB, 
 	    AS_AREA_READ | AS_AREA_WRITE, 0, &rtl8169->rx_buff_phys,
@@ -271,4 +284,7 @@
 	if (rc != EOK)
 		return rc;
+
+	ddf_msg(LVL_DEBUG, "RX buffers base address: phys=0x%08lx, virt=%p",
+	    rtl8169->rx_buff_phys, rtl8169->rx_buff);
 
 	return EOK;
@@ -556,4 +572,6 @@
 static int rtl8169_on_activated(nic_t *nic_data)
 {
+	int rc;
+
 	ddf_msg(LVL_NOTE, "Activating device");
 
@@ -565,5 +583,9 @@
 
 	/* Allocate buffers */
-	rtl8169_allocate_buffers(rtl8169);
+	rc = rtl8169_allocate_buffers(rtl8169);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Error allocating buffers: %d", rc);
+		return 0;
+	}
 
 	/* Initialize RX ring */
@@ -688,7 +710,8 @@
 	while (tail != head) {
 		descr = &rtl8169->tx_ring[tail];
-		descr->control |= CONTROL_OWN;
+		descr->control &= (~CONTROL_OWN);
+		write_barrier();
 		ddf_msg(LVL_NOTE, "TX status for descr %d: 0x%08x", tail, descr->control);
-
+	
 		tail = (tail + 1) % TX_BUFFERS_COUNT;
 	}
@@ -769,6 +792,9 @@
 
 	ddf_msg(LVL_NOTE, "rtl8169_irq_handler(): isr=0x%04x", isr);
+	pio_write_16(rtl8169->regs + IMR, 0xffff);
 
 	while (isr != 0) {
+		ddf_msg(LVL_DEBUG, "irq handler: remaining isr=0x%04x", isr);
+
 		/* Packet underrun or link change */
 		if (isr & INT_PUN) {
@@ -796,5 +822,4 @@
 	}
 
-	pio_write_16(rtl8169->regs + IMR, 0xffff);
 	pio_write_16(rtl8169->regs + ISR, 0xffff);
 }
@@ -816,8 +841,6 @@
 	fibril_mutex_lock(&rtl8169->tx_lock);
 
-	ddf_msg(LVL_NOTE, "send_frame()");
-	ddf_msg(LVL_NOTE, "size: %ld", size);
-	ddf_msg(LVL_NOTE, "tx ring virtual at %p", rtl8169->tx_ring);
-	ddf_msg(LVL_NOTE, "tx_head=%d tx_tail=%d", rtl8169->tx_head, rtl8169->tx_tail);
+	ddf_msg(LVL_NOTE, "send_frame: size: %ld, tx_head=%d tx_tail=%d",
+	    size, rtl8169->tx_head, rtl8169->tx_tail);
 
 	head = rtl8169->tx_head;
@@ -854,4 +877,6 @@
 	rtl8169->tx_head = (head + 1) % TX_BUFFERS_COUNT;
 
+	ddf_msg(LVL_DEBUG, "control: 0x%08x", descr->control);
+
 	write_barrier();
 
@@ -859,6 +884,4 @@
 	pio_write_8(rtl8169->regs + TPPOLL, TPPOLL_NPQ);
 	write_barrier();
-
-	ddf_msg(LVL_NOTE, "triggered TPPOLL");
 
 	fibril_mutex_unlock(&rtl8169->tx_lock);
