Index: uspace/drv/nic/e1k/e1k.c
===================================================================
--- uspace/drv/nic/e1k/e1k.c	(revision 99168415e54ff1af6c282693816440480e11aa65)
+++ uspace/drv/nic/e1k/e1k.c	(revision 7e1b13017debb7e2e2e1a385490bf064a2b1397d)
@@ -70,6 +70,6 @@
 
 /** nic_driver_data_t* -> e1000_t* cast */
-#define DRIVER_DATA_NIC(nic_data) \
-	((e1000_t *) nic_get_specific(nic_data))
+#define DRIVER_DATA_NIC(nic) \
+	((e1000_t *) nic_get_specific(nic))
 
 /** device_t* -> nic_driver_data_t* cast */
@@ -97,48 +97,66 @@
 #define MEMADDR_TO_PTR(memaddr)  ((void *) ((size_t) (memaddr)))
 
-#define E1000_REG_BASE(e1000_data) \
-	((e1000_data)->virt_reg_base)
-
-#define E1000_REG_ADDR(e1000_data, reg) \
-	((uint32_t *) (E1000_REG_BASE(e1000_data) + reg))
-
-#define E1000_REG_READ(e1000_data, reg) \
-	(pio_read_32(E1000_REG_ADDR(e1000_data, reg)))
-
-#define E1000_REG_WRITE(e1000_data, reg, value) \
-	(pio_write_32(E1000_REG_ADDR(e1000_data, reg), value))
+#define E1000_REG_BASE(e1000) \
+	((e1000)->reg_base_virt)
+
+#define E1000_REG_ADDR(e1000, reg) \
+	((uint32_t *) (E1000_REG_BASE(e1000) + reg))
+
+#define E1000_REG_READ(e1000, reg) \
+	(pio_read_32(E1000_REG_ADDR(e1000, reg)))
+
+#define E1000_REG_WRITE(e1000, reg, value) \
+	(pio_write_32(E1000_REG_ADDR(e1000, reg), value))
 
 /** E1000 device data */
-typedef struct e1000_data {
+typedef struct {
 	/** Physical registers base address */
-	void *phys_reg_base;
+	void *reg_base_phys;
 	/** Virtual registers base address */
-	void *virt_reg_base;
-	/** Tx ring */
-	dmamem_t tx_ring;
+	void *reg_base_virt;
+	
+	/** Physical tx ring address */
+	void *tx_ring_phys;
+	/** Virtual tx ring address */
+	void *tx_ring_virt;
+	
 	/** Packets in tx ring  */
 	packet_t **tx_ring_packets;
-	/** Rx ring */
-	dmamem_t rx_ring;
+	
+	/** Physical rx ring address */
+	void *rx_ring_phys;
+	/** Virtual rx ring address */
+	void *rx_ring_virt;
+	
 	/** Packets in rx ring  */
 	packet_t **rx_ring_packets;
+	
 	/** VLAN tag */
 	uint16_t vlan_tag;
+	
 	/** Add VLAN tag to packet */
 	bool vlan_tag_add;
+	
 	/** Used unicast Receive Address count */
 	unsigned int unicast_ra_count;
+	
 	/** Used milticast Receive addrress count */
 	unsigned int multicast_ra_count;
+	
 	/** PCI device ID */
 	uint16_t device_id;
+	
 	/** The irq assigned */
 	int irq;
+	
 	/** Lock for CTRL register */
 	fibril_mutex_t ctrl_lock;
+	
 	/** Lock for receiver */
 	fibril_mutex_t rx_lock;
+	
 	/** Lock for transmitter */
 	fibril_mutex_t tx_lock;
+	
 	/** Lock for EEPROM access */
 	fibril_mutex_t eeprom_lock;
@@ -225,5 +243,5 @@
 		.cmd = CMD_PIO_WRITE_32,
 		.addr = NULL,
-		.value = 0xFFFFFFFF
+		.value = 0xffffffff
 	},
 	{
@@ -280,6 +298,6 @@
 	assert(state);
 	
-	e1000_t *e1000_data = DRIVER_DATA_DEV(dev);
-	if (E1000_REG_READ(e1000_data, E1000_STATUS) & (STATUS_LU))
+	e1000_t *e1000 = DRIVER_DATA_DEV(dev);
+	if (E1000_REG_READ(e1000, E1000_STATUS) & (STATUS_LU))
 		*state = NIC_CS_PLUGGED;
 	else
@@ -300,6 +318,6 @@
     nic_channel_mode_t *duplex, nic_role_t *role)
 {
-	e1000_t *e1000_data = DRIVER_DATA_DEV(dev);
-	uint32_t status = E1000_REG_READ(e1000_data, E1000_STATUS);
+	e1000_t *e1000 = DRIVER_DATA_DEV(dev);
+	uint32_t status = E1000_REG_READ(e1000, E1000_STATUS);
 	
 	if (status & STATUS_FD)
@@ -323,21 +341,21 @@
 }
 
-static void e1000_link_restart(e1000_t * e1000_data)
-{
-	fibril_mutex_lock(&e1000_data->ctrl_lock);
-	
-	uint32_t ctrl = E1000_REG_READ(e1000_data, E1000_CTRL);
+static void e1000_link_restart(e1000_t *e1000)
+{
+	fibril_mutex_lock(&e1000->ctrl_lock);
+	
+	uint32_t ctrl = E1000_REG_READ(e1000, E1000_CTRL);
 	
 	if (ctrl & CTRL_SLU) {
 		ctrl &= ~(CTRL_SLU);
-		fibril_mutex_unlock(&e1000_data->ctrl_lock);
+		fibril_mutex_unlock(&e1000->ctrl_lock);
 		usleep(10);
-		fibril_mutex_lock(&e1000_data->ctrl_lock);
+		fibril_mutex_lock(&e1000->ctrl_lock);
 		ctrl |= CTRL_SLU;
 	}
 	
-	fibril_mutex_unlock(&e1000_data->ctrl_lock);
-	
-	e1000_link_restart(e1000_data);
+	fibril_mutex_unlock(&e1000->ctrl_lock);
+	
+	e1000_link_restart(e1000);
 }
 
@@ -354,8 +372,8 @@
 		return EINVAL;
 	
-	e1000_t *e1000_data = DRIVER_DATA_DEV(dev);
-	
-	fibril_mutex_lock(&e1000_data->ctrl_lock);
-	uint32_t ctrl = E1000_REG_READ(e1000_data, E1000_CTRL);
+	e1000_t *e1000 = DRIVER_DATA_DEV(dev);
+	
+	fibril_mutex_lock(&e1000->ctrl_lock);
+	uint32_t ctrl = E1000_REG_READ(e1000, E1000_CTRL);
 	
 	ctrl |= CTRL_FRCSPD;
@@ -376,9 +394,9 @@
 		ctrl |= CTRL_SPEED_10 << CTRL_SPEED_SHIFT;
 	
-	E1000_REG_WRITE(e1000_data, E1000_CTRL, ctrl);
-	
-	fibril_mutex_unlock(&e1000_data->ctrl_lock);
-	
-	e1000_link_restart(e1000_data);
+	E1000_REG_WRITE(e1000, E1000_CTRL, ctrl);
+	
+	fibril_mutex_unlock(&e1000->ctrl_lock);
+	
+	e1000_link_restart(e1000);
 	
 	return EOK;
@@ -395,9 +413,9 @@
 static int e1000_autoneg_enable(ddf_fun_t *dev, uint32_t advertisement)
 {
-	e1000_t *e1000_data = DRIVER_DATA_DEV(dev);
-	
-	fibril_mutex_lock(&e1000_data->ctrl_lock);
-	
-	uint32_t ctrl = E1000_REG_READ(e1000_data, E1000_CTRL);
+	e1000_t *e1000 = DRIVER_DATA_DEV(dev);
+	
+	fibril_mutex_lock(&e1000->ctrl_lock);
+	
+	uint32_t ctrl = E1000_REG_READ(e1000, E1000_CTRL);
 	
 	ctrl &= ~(CTRL_FRCSPD);
@@ -405,9 +423,9 @@
 	ctrl |= CTRL_ASDE;
 	
-	E1000_REG_WRITE(e1000_data, E1000_CTRL, ctrl);
-	
-	fibril_mutex_unlock(&e1000_data->ctrl_lock);
-	
-	e1000_link_restart(e1000_data);
+	E1000_REG_WRITE(e1000, E1000_CTRL, ctrl);
+	
+	fibril_mutex_unlock(&e1000->ctrl_lock);
+	
+	e1000_link_restart(e1000);
 	
 	return EOK;
@@ -423,9 +441,9 @@
 static int e1000_autoneg_disable(ddf_fun_t *dev)
 {
-	e1000_t *e1000_data = DRIVER_DATA_DEV(dev);
-	
-	fibril_mutex_lock(&e1000_data->ctrl_lock);
-	
-	uint32_t ctrl = E1000_REG_READ(e1000_data, E1000_CTRL);
+	e1000_t *e1000 = DRIVER_DATA_DEV(dev);
+	
+	fibril_mutex_lock(&e1000->ctrl_lock);
+	
+	uint32_t ctrl = E1000_REG_READ(e1000, E1000_CTRL);
 	
 	ctrl |= CTRL_FRCSPD;
@@ -433,9 +451,9 @@
 	ctrl &= ~(CTRL_ASDE);
 	
-	E1000_REG_WRITE(e1000_data, E1000_CTRL, ctrl);
-	
-	fibril_mutex_unlock(&e1000_data->ctrl_lock);
-	
-	e1000_link_restart(e1000_data);
+	E1000_REG_WRITE(e1000, E1000_CTRL, ctrl);
+	
+	fibril_mutex_unlock(&e1000->ctrl_lock);
+	
+	e1000_link_restart(e1000);
 	
 	return EOK;
@@ -462,8 +480,8 @@
 static int e1000_defective_get_mode(ddf_fun_t *device, uint32_t *mode)
 {
-	e1000_t *e1000_data = DRIVER_DATA_DEV(device);
+	e1000_t *e1000 = DRIVER_DATA_DEV(device);
 	
 	*mode = 0;
-	uint32_t rctl = E1000_REG_READ(e1000_data, E1000_RCTL);
+	uint32_t rctl = E1000_REG_READ(e1000, E1000_RCTL);
 	if (rctl & RCTL_SBP)
 		*mode = NIC_DEFECTIVE_BAD_CRC | NIC_DEFECTIVE_SHORT;
@@ -483,10 +501,10 @@
 static int e1000_defective_set_mode(ddf_fun_t *device, uint32_t mode)
 {
-	e1000_t *e1000_data = DRIVER_DATA_DEV(device);
+	e1000_t *e1000 = DRIVER_DATA_DEV(device);
 	int rc = EOK;
 	
-	fibril_mutex_lock(&e1000_data->rx_lock);
-	
-	uint32_t rctl = E1000_REG_READ(e1000_data, E1000_RCTL);
+	fibril_mutex_lock(&e1000->rx_lock);
+	
+	uint32_t rctl = E1000_REG_READ(e1000, E1000_RCTL);
 	bool short_mode = (mode & NIC_DEFECTIVE_SHORT ? true : false);
 	bool bad_mode = (mode & NIC_DEFECTIVE_BAD_CRC ? true : false);
@@ -499,7 +517,7 @@
 		rc = ENOTSUP;
 	
-	E1000_REG_WRITE(e1000_data, E1000_RCTL, rctl);
-	
-	fibril_mutex_unlock(&e1000_data->rx_lock);
+	E1000_REG_WRITE(e1000, E1000_RCTL, rctl);
+	
+	fibril_mutex_unlock(&e1000->rx_lock);
 	return rc;
 };
@@ -507,5 +525,5 @@
 /** Write receive address to RA registr
  *
- * @param e1000_data E1000 data structure
+ * @param e1000      E1000 data structure
  * @param position   RA register position
  * @param address    Ethernet address
@@ -513,7 +531,6 @@
  *
  */
-static void e1000_write_receive_address(e1000_t *e1000_data,
-    unsigned int position, const nic_address_t * address,
-    bool set_av_bit)
+static void e1000_write_receive_address(e1000_t *e1000, unsigned int position,
+    const nic_address_t * address, bool set_av_bit)
 {
 	uint8_t *mac0 = (uint8_t *) address->address;
@@ -533,9 +550,8 @@
 		rah |= RAH_AV;
 	else
-		rah |= E1000_REG_READ(e1000_data, E1000_RAH_ARRAY(position)) &
-		    RAH_AV;
-	
-	E1000_REG_WRITE(e1000_data, E1000_RAH_ARRAY(position), rah);
-	E1000_REG_WRITE(e1000_data, E1000_RAL_ARRAY(position), ral);
+		rah |= E1000_REG_READ(e1000, E1000_RAH_ARRAY(position)) & RAH_AV;
+	
+	E1000_REG_WRITE(e1000, E1000_RAH_ARRAY(position), rah);
+	E1000_REG_WRITE(e1000, E1000_RAL_ARRAY(position), ral);
 }
 
@@ -544,85 +560,83 @@
  *  Clear Address Valid bit
  *
- * @param e1000_data E1000 data structure
- * @param position   RA register position
- *
- */
-static void e1000_disable_receive_address(e1000_t *e1000_data,
-    unsigned int position)
-{
-	uint32_t rah =
-	    E1000_REG_READ(e1000_data, E1000_RAH_ARRAY(position));
+ * @param e1000    E1000 data structure
+ * @param position RA register position
+ *
+ */
+static void e1000_disable_receive_address(e1000_t *e1000, unsigned int position)
+{
+	uint32_t rah = E1000_REG_READ(e1000, E1000_RAH_ARRAY(position));
 	rah = rah & ~RAH_AV;
-	E1000_REG_WRITE(e1000_data, E1000_RAH_ARRAY(position), rah);
+	E1000_REG_WRITE(e1000, E1000_RAH_ARRAY(position), rah);
 }
 
 /** Clear all unicast addresses from RA registers
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_clear_unicast_receive_addresses(e1000_t *e1000_data)
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_clear_unicast_receive_addresses(e1000_t *e1000)
 {
 	for (unsigned int ra_num = 1;
-	    ra_num <= e1000_data->unicast_ra_count;
+	    ra_num <= e1000->unicast_ra_count;
 	    ra_num++)
-		e1000_disable_receive_address(e1000_data, ra_num);
-	
-	e1000_data->unicast_ra_count = 0;
+		e1000_disable_receive_address(e1000, ra_num);
+	
+	e1000->unicast_ra_count = 0;
 }
 
 /** Clear all multicast addresses from RA registers
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_clear_multicast_receive_addresses(e1000_t *e1000_data)
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_clear_multicast_receive_addresses(e1000_t *e1000)
 {
 	unsigned int first_multicast_ra_num =
-	    E1000_RECEIVE_ADDRESS - e1000_data->multicast_ra_count;
+	    E1000_RECEIVE_ADDRESS - e1000->multicast_ra_count;
 	
 	for (unsigned int ra_num = E1000_RECEIVE_ADDRESS - 1;
 	    ra_num >= first_multicast_ra_num;
 	    ra_num--)
-		e1000_disable_receive_address(e1000_data, ra_num);
-	
-	e1000_data->multicast_ra_count = 0;
+		e1000_disable_receive_address(e1000, ra_num);
+	
+	e1000->multicast_ra_count = 0;
 }
 
 /** Return receive address filter positions count usable for unicast
  *
- * @param e1000_data E1000 data structure
+ * @param e1000 E1000 data structure
  *
  * @return receive address filter positions count usable for unicast
  *
  */
-static unsigned int get_free_unicast_address_count(e1000_t *e1000_data)
-{
-	return E1000_RECEIVE_ADDRESS - 1 - e1000_data->multicast_ra_count;
+static unsigned int get_free_unicast_address_count(e1000_t *e1000)
+{
+	return E1000_RECEIVE_ADDRESS - 1 - e1000->multicast_ra_count;
 }
 
 /** Return receive address filter positions count usable for multicast
  *
- * @param e1000_data E1000 data structure
+ * @param e1000 E1000 data structure
  *
  * @return receive address filter positions count usable for multicast
  *
  */
-static unsigned int get_free_multicast_address_count(e1000_t *e1000_data)
-{
-	return E1000_RECEIVE_ADDRESS - 1 - e1000_data->unicast_ra_count;
+static unsigned int get_free_multicast_address_count(e1000_t *e1000)
+{
+	return E1000_RECEIVE_ADDRESS - 1 - e1000->unicast_ra_count;
 }
 
 /** Write unicast receive addresses to receive address filter registers
  *
- * @param e1000_data E1000 data structure
- * @param addr       Pointer to address array
- * @param addr_cnt   Address array count
- *
- */
-static void e1000_add_unicast_receive_addresses(e1000_t *e1000_data,
+ * @param e1000    E1000 data structure
+ * @param addr     Pointer to address array
+ * @param addr_cnt Address array count
+ *
+ */
+static void e1000_add_unicast_receive_addresses(e1000_t *e1000,
     const nic_address_t *addr, size_t addr_cnt)
 {
-	assert(addr_cnt <= get_free_unicast_address_count(e1000_data));
+	assert(addr_cnt <= get_free_unicast_address_count(e1000));
 	
 	nic_address_t *addr_iterator = (nic_address_t *) addr;
@@ -632,5 +646,5 @@
 	    ra_num <= addr_cnt;
 	    ra_num++) {
-		e1000_write_receive_address(e1000_data, ra_num, addr_iterator, true);
+		e1000_write_receive_address(e1000, ra_num, addr_iterator, true);
 		addr_iterator++;
 	}
@@ -639,13 +653,13 @@
 /** Write multicast receive addresses to receive address filter registers
  *
- * @param e1000_data E1000 data structure
- * @param addr       Pointer to address array
- * @param addr_cnt   Address array count
- *
- */
-static void e1000_add_multicast_receive_addresses(e1000_t *e1000_data,
+ * @param e1000    E1000 data structure
+ * @param addr     Pointer to address array
+ * @param addr_cnt Address array count
+ *
+ */
+static void e1000_add_multicast_receive_addresses(e1000_t *e1000,
     const nic_address_t *addr, size_t addr_cnt)
 {
-	assert(addr_cnt <= get_free_multicast_address_count(e1000_data));
+	assert(addr_cnt <= get_free_multicast_address_count(e1000));
 	
 	nic_address_t *addr_iterator = (nic_address_t *) addr;
@@ -655,5 +669,5 @@
 	    ra_num >= first_multicast_ra_num;
 	    ra_num--) {
-		e1000_write_receive_address(e1000_data, ra_num, addr_iterator, true);
+		e1000_write_receive_address(e1000, ra_num, addr_iterator, true);
 		addr_iterator++;
 	}
@@ -662,125 +676,125 @@
 /** Disable receiving packets for default address
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void disable_ra0_address_filter(e1000_t *e1000_data)
-{
-	uint32_t rah0 = E1000_REG_READ(e1000_data, E1000_RAH_ARRAY(0));
+ * @param e1000 E1000 data structure
+ *
+ */
+static void disable_ra0_address_filter(e1000_t *e1000)
+{
+	uint32_t rah0 = E1000_REG_READ(e1000, E1000_RAH_ARRAY(0));
 	rah0 = rah0 & ~RAH_AV;
-	E1000_REG_WRITE(e1000_data, E1000_RAH_ARRAY(0), rah0);
+	E1000_REG_WRITE(e1000, E1000_RAH_ARRAY(0), rah0);
 }
 
 /** Enable receiving packets for default address
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void enable_ra0_address_filter(e1000_t *e1000_data)
-{
-	uint32_t rah0 = E1000_REG_READ(e1000_data, E1000_RAH_ARRAY(0));
+ * @param e1000 E1000 data structure
+ *
+ */
+static void enable_ra0_address_filter(e1000_t *e1000)
+{
+	uint32_t rah0 = E1000_REG_READ(e1000, E1000_RAH_ARRAY(0));
 	rah0 = rah0 | RAH_AV;
-	E1000_REG_WRITE(e1000_data, E1000_RAH_ARRAY(0), rah0);
+	E1000_REG_WRITE(e1000, E1000_RAH_ARRAY(0), rah0);
 }
 
 /** Disable unicast promiscuous mode
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_disable_unicast_promisc(e1000_t *e1000_data)
-{
-	uint32_t rctl = E1000_REG_READ(e1000_data, E1000_RCTL);
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_disable_unicast_promisc(e1000_t *e1000)
+{
+	uint32_t rctl = E1000_REG_READ(e1000, E1000_RCTL);
 	rctl = rctl & ~RCTL_UPE;
-	E1000_REG_WRITE(e1000_data, E1000_RCTL, rctl);
+	E1000_REG_WRITE(e1000, E1000_RCTL, rctl);
 }
 
 /** Enable unicast promiscuous mode
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_enable_unicast_promisc(e1000_t *e1000_data)
-{
-	uint32_t rctl = E1000_REG_READ(e1000_data, E1000_RCTL);
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_enable_unicast_promisc(e1000_t *e1000)
+{
+	uint32_t rctl = E1000_REG_READ(e1000, E1000_RCTL);
 	rctl = rctl | RCTL_UPE;
-	E1000_REG_WRITE(e1000_data, E1000_RCTL, rctl);
+	E1000_REG_WRITE(e1000, E1000_RCTL, rctl);
 }
 
 /** Disable multicast promiscuous mode
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_disable_multicast_promisc(e1000_t *e1000_data)
-{
-	uint32_t rctl = E1000_REG_READ(e1000_data, E1000_RCTL);
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_disable_multicast_promisc(e1000_t *e1000)
+{
+	uint32_t rctl = E1000_REG_READ(e1000, E1000_RCTL);
 	rctl = rctl & ~RCTL_MPE;
-	E1000_REG_WRITE(e1000_data, E1000_RCTL, rctl);
+	E1000_REG_WRITE(e1000, E1000_RCTL, rctl);
 }
 
 /** Enable multicast promiscuous mode
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_enable_multicast_promisc(e1000_t *e1000_data)
-{
-	uint32_t rctl = E1000_REG_READ(e1000_data, E1000_RCTL);
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_enable_multicast_promisc(e1000_t *e1000)
+{
+	uint32_t rctl = E1000_REG_READ(e1000, E1000_RCTL);
 	rctl = rctl | RCTL_MPE;
-	E1000_REG_WRITE(e1000_data, E1000_RCTL, rctl);
+	E1000_REG_WRITE(e1000, E1000_RCTL, rctl);
 }
 
 /** Enable accepting of broadcast packets
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_enable_broadcast_accept(e1000_t *e1000_data)
-{
-	uint32_t rctl = E1000_REG_READ(e1000_data, E1000_RCTL);
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_enable_broadcast_accept(e1000_t *e1000)
+{
+	uint32_t rctl = E1000_REG_READ(e1000, E1000_RCTL);
 	rctl = rctl | RCTL_BAM;
-	E1000_REG_WRITE(e1000_data, E1000_RCTL, rctl);
+	E1000_REG_WRITE(e1000, E1000_RCTL, rctl);
 }
 
 /** Disable accepting of broadcast packets
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_disable_broadcast_accept(e1000_t *e1000_data)
-{
-	uint32_t rctl = E1000_REG_READ(e1000_data, E1000_RCTL);
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_disable_broadcast_accept(e1000_t *e1000)
+{
+	uint32_t rctl = E1000_REG_READ(e1000, E1000_RCTL);
 	rctl = rctl & ~RCTL_BAM;
-	E1000_REG_WRITE(e1000_data, E1000_RCTL, rctl);
+	E1000_REG_WRITE(e1000, E1000_RCTL, rctl);
 }
 
 /** Enable VLAN filtering according to VFTA registers
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_enable_vlan_filter(e1000_t *e1000_data)
-{
-	uint32_t rctl = E1000_REG_READ(e1000_data, E1000_RCTL);
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_enable_vlan_filter(e1000_t *e1000)
+{
+	uint32_t rctl = E1000_REG_READ(e1000, E1000_RCTL);
 	rctl = rctl | RCTL_VFE;
-	E1000_REG_WRITE(e1000_data, E1000_RCTL, rctl);
+	E1000_REG_WRITE(e1000, E1000_RCTL, rctl);
 }
 
 /** Disable VLAN filtering
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_disable_vlan_filter(e1000_t *e1000_data)
-{
-	uint32_t rctl = E1000_REG_READ(e1000_data, E1000_RCTL);
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_disable_vlan_filter(e1000_t *e1000)
+{
+	uint32_t rctl = E1000_REG_READ(e1000, E1000_RCTL);
 	rctl = rctl & ~RCTL_VFE;
-	E1000_REG_WRITE(e1000_data, E1000_RCTL, rctl);
+	E1000_REG_WRITE(e1000, E1000_RCTL, rctl);
 }
 
 /** Set multicast packets acceptance mode
  *
- * @param nic_data NIC device to update
+ * @param nic      NIC device to update
  * @param mode     Mode to set
  * @param addr     Address list (used in mode = NIC_MULTICAST_LIST)
@@ -790,21 +804,21 @@
  *
  */
-static int e1000_on_multicast_mode_change(nic_t *nic_data,
-    nic_multicast_mode_t mode, const nic_address_t *addr, size_t addr_cnt)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
+static int e1000_on_multicast_mode_change(nic_t *nic, nic_multicast_mode_t mode,
+    const nic_address_t *addr, size_t addr_cnt)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
 	int rc = EOK;
 	
-	fibril_mutex_lock(&e1000_data->rx_lock);
+	fibril_mutex_lock(&e1000->rx_lock);
 	
 	switch (mode) {
 	case NIC_MULTICAST_BLOCKED:
-		e1000_clear_multicast_receive_addresses(e1000_data);
-		e1000_disable_multicast_promisc(e1000_data);
-		nic_report_hw_filtering(nic_data, -1, 1, -1);
+		e1000_clear_multicast_receive_addresses(e1000);
+		e1000_disable_multicast_promisc(e1000);
+		nic_report_hw_filtering(nic, -1, 1, -1);
 		break;
 	case NIC_MULTICAST_LIST:
-		e1000_clear_multicast_receive_addresses(e1000_data);
-		if (addr_cnt > get_free_multicast_address_count(e1000_data)) {
+		e1000_clear_multicast_receive_addresses(e1000);
+		if (addr_cnt > get_free_multicast_address_count(e1000)) {
 			/*
 			 * Future work: fill MTA table
@@ -812,16 +826,16 @@
 			 * in the NIC library.
 			 */
-			e1000_enable_multicast_promisc(e1000_data);
-			nic_report_hw_filtering(nic_data, -1, 0, -1);
+			e1000_enable_multicast_promisc(e1000);
+			nic_report_hw_filtering(nic, -1, 0, -1);
 		} else {
-			e1000_disable_multicast_promisc(e1000_data);
-			e1000_add_multicast_receive_addresses(e1000_data, addr, addr_cnt);
-			nic_report_hw_filtering(nic_data, -1, 1, -1);
+			e1000_disable_multicast_promisc(e1000);
+			e1000_add_multicast_receive_addresses(e1000, addr, addr_cnt);
+			nic_report_hw_filtering(nic, -1, 1, -1);
 		}
 		break;
 	case NIC_MULTICAST_PROMISC:
-		e1000_enable_multicast_promisc(e1000_data);
-		e1000_clear_multicast_receive_addresses(e1000_data);
-		nic_report_hw_filtering(nic_data, -1, 1, -1);
+		e1000_enable_multicast_promisc(e1000);
+		e1000_clear_multicast_receive_addresses(e1000);
+		nic_report_hw_filtering(nic, -1, 1, -1);
 		break;
 	default:
@@ -830,5 +844,5 @@
 	}
 	
-	fibril_mutex_unlock(&e1000_data->rx_lock);
+	fibril_mutex_unlock(&e1000->rx_lock);
 	return rc;
 }
@@ -836,5 +850,5 @@
 /** Set unicast packets acceptance mode
  *
- * @param nic_data NIC device to update
+ * @param nic      NIC device to update
  * @param mode     Mode to set
  * @param addr     Address list (used in mode = NIC_MULTICAST_LIST)
@@ -844,42 +858,42 @@
  *
  */
-static int e1000_on_unicast_mode_change(nic_t *nic_data,
-    nic_unicast_mode_t mode, const nic_address_t *addr, size_t addr_cnt)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
+static int e1000_on_unicast_mode_change(nic_t *nic, nic_unicast_mode_t mode,
+    const nic_address_t *addr, size_t addr_cnt)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
 	int rc = EOK;
 	
-	fibril_mutex_lock(&e1000_data->rx_lock);
+	fibril_mutex_lock(&e1000->rx_lock);
 	
 	switch (mode) {
 	case NIC_UNICAST_BLOCKED:
-		disable_ra0_address_filter(e1000_data);
-		e1000_clear_unicast_receive_addresses(e1000_data);
-		e1000_disable_unicast_promisc(e1000_data);
-		nic_report_hw_filtering(nic_data, 1, -1, -1);
+		disable_ra0_address_filter(e1000);
+		e1000_clear_unicast_receive_addresses(e1000);
+		e1000_disable_unicast_promisc(e1000);
+		nic_report_hw_filtering(nic, 1, -1, -1);
 		break;
 	case NIC_UNICAST_DEFAULT:
-		enable_ra0_address_filter(e1000_data);
-		e1000_clear_unicast_receive_addresses(e1000_data);
-		e1000_disable_unicast_promisc(e1000_data);
-		nic_report_hw_filtering(nic_data, 1, -1, -1);
+		enable_ra0_address_filter(e1000);
+		e1000_clear_unicast_receive_addresses(e1000);
+		e1000_disable_unicast_promisc(e1000);
+		nic_report_hw_filtering(nic, 1, -1, -1);
 		break;
 	case NIC_UNICAST_LIST:
-		enable_ra0_address_filter(e1000_data);
-		e1000_clear_unicast_receive_addresses(e1000_data);
-		if (addr_cnt > get_free_unicast_address_count(e1000_data)) {
-			e1000_enable_unicast_promisc(e1000_data);
-			nic_report_hw_filtering(nic_data, 0, -1, -1);
+		enable_ra0_address_filter(e1000);
+		e1000_clear_unicast_receive_addresses(e1000);
+		if (addr_cnt > get_free_unicast_address_count(e1000)) {
+			e1000_enable_unicast_promisc(e1000);
+			nic_report_hw_filtering(nic, 0, -1, -1);
 		} else {
-			e1000_disable_unicast_promisc(e1000_data);
-			e1000_add_unicast_receive_addresses(e1000_data, addr, addr_cnt);
-			nic_report_hw_filtering(nic_data, 1, -1, -1);
+			e1000_disable_unicast_promisc(e1000);
+			e1000_add_unicast_receive_addresses(e1000, addr, addr_cnt);
+			nic_report_hw_filtering(nic, 1, -1, -1);
 		}
 		break;
 	case NIC_UNICAST_PROMISC:
-		e1000_enable_unicast_promisc(e1000_data);
-		enable_ra0_address_filter(e1000_data);
-		e1000_clear_unicast_receive_addresses(e1000_data);
-		nic_report_hw_filtering(nic_data, 1, -1, -1);
+		e1000_enable_unicast_promisc(e1000);
+		enable_ra0_address_filter(e1000);
+		e1000_clear_unicast_receive_addresses(e1000);
+		nic_report_hw_filtering(nic, 1, -1, -1);
 		break;
 	default:
@@ -888,5 +902,5 @@
 	}
 	
-	fibril_mutex_unlock(&e1000_data->rx_lock);
+	fibril_mutex_unlock(&e1000->rx_lock);
 	return rc;
 }
@@ -894,24 +908,23 @@
 /** Set broadcast packets acceptance mode
  *
- * @param nic_data NIC device to update
- * @param mode     Mode to set
+ * @param nic  NIC device to update
+ * @param mode Mode to set
  *
  * @return EOK
  *
  */
-static int e1000_on_broadcast_mode_change(nic_t *nic_data,
-    nic_broadcast_mode_t mode)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
+static int e1000_on_broadcast_mode_change(nic_t *nic, nic_broadcast_mode_t mode)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
 	int rc = EOK;
 	
-	fibril_mutex_lock(&e1000_data->rx_lock);
+	fibril_mutex_lock(&e1000->rx_lock);
 	
 	switch (mode) {
 	case NIC_BROADCAST_BLOCKED:
-		e1000_disable_broadcast_accept(e1000_data);
+		e1000_disable_broadcast_accept(e1000);
 		break;
 	case NIC_BROADCAST_ACCEPTED:
-		e1000_enable_broadcast_accept(e1000_data);
+		e1000_enable_broadcast_accept(e1000);
 		break;
 	default:
@@ -920,5 +933,5 @@
 	}
 	
-	fibril_mutex_unlock(&e1000_data->rx_lock);
+	fibril_mutex_unlock(&e1000->rx_lock);
 	return rc;
 }
@@ -926,12 +939,12 @@
 /** Check if receiving is enabled
  *
- * @param e1000_data E1000 data structure
+ * @param e1000 E1000 data structure
  *
  * @return true if receiving is enabled
  *
  */
-static bool e1000_is_rx_enabled(e1000_t *e1000_data)
-{
-	if (E1000_REG_READ(e1000_data, E1000_RCTL) & (RCTL_EN))
+static bool e1000_is_rx_enabled(e1000_t *e1000)
+{
+	if (E1000_REG_READ(e1000, E1000_RCTL) & (RCTL_EN))
 		return true;
 	
@@ -941,38 +954,38 @@
 /** Enable receiving
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_enable_rx(e1000_t *e1000_data)
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_enable_rx(e1000_t *e1000)
 {
 	/* Set Receive Enable Bit */
-	E1000_REG_WRITE(e1000_data, E1000_RCTL,
-	    E1000_REG_READ(e1000_data, E1000_RCTL) | (RCTL_EN));
+	E1000_REG_WRITE(e1000, E1000_RCTL,
+	    E1000_REG_READ(e1000, E1000_RCTL) | (RCTL_EN));
 }
 
 /** Disable receiving
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_disable_rx(e1000_t *e1000_data)
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_disable_rx(e1000_t *e1000)
 {
 	/* Clear Receive Enable Bit */
-	E1000_REG_WRITE(e1000_data, E1000_RCTL,
-	    E1000_REG_READ(e1000_data, E1000_RCTL) & ~(RCTL_EN));
+	E1000_REG_WRITE(e1000, E1000_RCTL,
+	    E1000_REG_READ(e1000, E1000_RCTL) & ~(RCTL_EN));
 }
 
 /** Set VLAN mask
  *
- * @param nic_data  NIC device to update
+ * @param nic       NIC device to update
  * @param vlan_mask VLAN mask
  *
  */
-static void e1000_on_vlan_mask_change(nic_t *nic_data,
-   const nic_vlan_mask_t *vlan_mask)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
-	
-	fibril_mutex_lock(&e1000_data->rx_lock);
+static void e1000_on_vlan_mask_change(nic_t *nic,
+    const nic_vlan_mask_t *vlan_mask)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
+	
+	fibril_mutex_lock(&e1000->rx_lock);
 	
 	if (vlan_mask) {
@@ -981,7 +994,7 @@
 		 * partially written VLAN is not received.
 		 */
-		bool rx_enabled = e1000_is_rx_enabled(e1000_data);
+		bool rx_enabled = e1000_is_rx_enabled(e1000);
 		if (rx_enabled)
-			e1000_disable_rx(e1000_data);
+			e1000_disable_rx(e1000);
 		
 		for (unsigned int i = 0; i < NIC_VLAN_BITMAP_SIZE; i += 4) {
@@ -991,14 +1004,14 @@
 			    (((uint32_t) vlan_mask->bitmap[i + 2]) << 16) |
 			    (((uint32_t) vlan_mask->bitmap[i + 3]) << 24);
-			E1000_REG_WRITE(e1000_data, E1000_VFTA_ARRAY(i / 4), bitmap_part);
+			E1000_REG_WRITE(e1000, E1000_VFTA_ARRAY(i / 4), bitmap_part);
 		}
 		
-		e1000_enable_vlan_filter(e1000_data);
+		e1000_enable_vlan_filter(e1000);
 		if (rx_enabled)
-			e1000_enable_rx(e1000_data);
+			e1000_enable_rx(e1000);
 	} else
-		e1000_disable_vlan_filter(e1000_data);
-	
-	fibril_mutex_unlock(&e1000_data->rx_lock);
+		e1000_disable_vlan_filter(e1000);
+	
+	fibril_mutex_unlock(&e1000->rx_lock);
 }
 
@@ -1026,12 +1039,12 @@
 		return ENOTSUP;
 	
-	e1000_t *e1000_data = DRIVER_DATA_DEV(device);
-	
-	e1000_data->vlan_tag = tag;
-	e1000_data->vlan_tag_add = add;
-	
-	fibril_mutex_lock(&e1000_data->ctrl_lock);
-	
-	uint32_t ctrl = E1000_REG_READ(e1000_data, E1000_CTRL);
+	e1000_t *e1000 = DRIVER_DATA_DEV(device);
+	
+	e1000->vlan_tag = tag;
+	e1000->vlan_tag_add = add;
+	
+	fibril_mutex_lock(&e1000->ctrl_lock);
+	
+	uint32_t ctrl = E1000_REG_READ(e1000, E1000_CTRL);
 	if (strip)
 		ctrl |= CTRL_VME;
@@ -1039,7 +1052,7 @@
 		ctrl &= ~CTRL_VME;
 	
-	E1000_REG_WRITE(e1000_data, E1000_CTRL, ctrl);
-	
-	fibril_mutex_unlock(&e1000_data->ctrl_lock);
+	E1000_REG_WRITE(e1000, E1000_CTRL, ctrl);
+	
+	fibril_mutex_unlock(&e1000->ctrl_lock);
 	return EOK;
 }
@@ -1047,28 +1060,29 @@
 /** Fill receive descriptor with new empty packet
  *
- * Store packet in e1000_data->rx_ring_packets
- *
- * @param nic_data NIC data stricture
- * @param offset   Receive descriptor offset
- *
- */
-static void e1000_fill_new_rx_descriptor(nic_t *nic_data, unsigned int offset)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
-	packet_t *packet = nic_alloc_packet(nic_data, E1000_MAX_RECEIVE_PACKET_SIZE);
+ * Store packet in e1000->rx_ring_packets
+ *
+ * @param nic    NIC data stricture
+ * @param offset Receive descriptor offset
+ *
+ */
+static void e1000_fill_new_rx_descriptor(nic_t *nic, size_t offset)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
+	packet_t *packet =
+	    nic_alloc_packet(nic, E1000_MAX_RECEIVE_PACKET_SIZE);
 	
 	assert(packet);
 	
-	*(e1000_data->rx_ring_packets + offset) = packet;
-	e1000_rx_descriptor_t * rx_descriptor = (e1000_rx_descriptor_t *)
-	    (e1000_data->rx_ring.virt +
-	    offset * sizeof(e1000_rx_descriptor_t));
-	
-	void *phys_addr = nic_dma_lock_packet(packet);
-	
-	if (phys_addr) {
-		rx_descriptor->phys_addr =
-		    PTR_TO_U64(phys_addr + packet->data_start);
-	} else
+	*(e1000->rx_ring_packets + offset) = packet;
+	e1000_rx_descriptor_t *rx_descriptor = (e1000_rx_descriptor_t *)
+	    (e1000->rx_ring_virt + offset * sizeof(e1000_rx_descriptor_t));
+	
+	void *phys;
+	int rc =
+	    nic_dma_lock_packet(packet, E1000_MAX_RECEIVE_PACKET_SIZE, &phys);
+	
+	if (rc == EOK)
+		rx_descriptor->phys_addr = PTR_TO_U64(phys + packet->data_start);
+	else
 		rx_descriptor->phys_addr = 0;
 	
@@ -1082,13 +1096,12 @@
 /** Clear receive descriptor
  *
- * @param e1000_data E1000 data
- * @param offset     Receive descriptor offset
- *
- */
-static void e1000_clear_rx_descriptor(e1000_t *e1000_data, unsigned int offset)
+ * @param e1000  E1000 data
+ * @param offset Receive descriptor offset
+ *
+ */
+static void e1000_clear_rx_descriptor(e1000_t *e1000, unsigned int offset)
 {
 	e1000_rx_descriptor_t *rx_descriptor = (e1000_rx_descriptor_t *)
-	    (e1000_data->rx_ring.virt +
-	    offset * sizeof(e1000_rx_descriptor_t));
+	    (e1000->rx_ring_virt + offset * sizeof(e1000_rx_descriptor_t));
 	
 	rx_descriptor->length = 0;
@@ -1101,20 +1114,19 @@
 /** Clear receive descriptor
  *
- * @param nic_data NIC data
- * @param offset   Receive descriptor offset
- *
- */
-static void e1000_clear_tx_descriptor(nic_t *nic_data, unsigned int offset)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
-	
-	e1000_tx_descriptor_t * tx_descriptor = (e1000_tx_descriptor_t *)
-	    (e1000_data->tx_ring.virt +
-	    offset * sizeof(e1000_tx_descriptor_t));
+ * @param nic    NIC data
+ * @param offset Receive descriptor offset
+ *
+ */
+static void e1000_clear_tx_descriptor(nic_t *nic, unsigned int offset)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
+	
+	e1000_tx_descriptor_t *tx_descriptor = (e1000_tx_descriptor_t *)
+	    (e1000->tx_ring_virt + offset * sizeof(e1000_tx_descriptor_t));
 	
 	if (tx_descriptor->length) {
-		packet_t * old_packet = *(e1000_data->tx_ring_packets + offset);
+		packet_t *old_packet = *(e1000->tx_ring_packets + offset);
 		if (old_packet)
-			nic_release_packet(nic_data, old_packet);
+			nic_release_packet(nic, old_packet);
 	}
 	
@@ -1146,30 +1158,29 @@
 /** Receive packets
  *
- * @param nic_data NIC data
- *
- */
-static void e1000_receive_packets(nic_t *nic_data)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
-	
-	fibril_mutex_lock(&e1000_data->rx_lock);
-	
-	uint32_t *tail_addr = E1000_REG_ADDR(e1000_data, E1000_RDT);
+ * @param nic NIC data
+ *
+ */
+static void e1000_receive_packets(nic_t *nic)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
+	
+	fibril_mutex_lock(&e1000->rx_lock);
+	
+	uint32_t *tail_addr = E1000_REG_ADDR(e1000, E1000_RDT);
 	uint32_t next_tail = e1000_inc_tail(*tail_addr, E1000_RX_PACKETS_COUNT);
 	
 	e1000_rx_descriptor_t *rx_descriptor = (e1000_rx_descriptor_t *)
-	    (e1000_data->rx_ring.virt +
-	    next_tail * sizeof(e1000_rx_descriptor_t));
+	    (e1000->rx_ring_virt + next_tail * sizeof(e1000_rx_descriptor_t));
 	
 	while (rx_descriptor->status & 0x01) {
 		uint32_t packet_size = rx_descriptor->length - E1000_CRC_SIZE;
 		
-		packet_t *packet = *(e1000_data->rx_ring_packets + next_tail);
+		packet_t *packet = *(e1000->rx_ring_packets + next_tail);
 		packet_suffix(packet, packet_size);
 		
-		nic_dma_unlock_packet(packet);
-		nic_received_packet(nic_data, packet);
+		nic_dma_unlock_packet(packet, E1000_MAX_RECEIVE_PACKET_SIZE);
+		nic_received_packet(nic, packet);
 		
-		e1000_fill_new_rx_descriptor(nic_data, next_tail);
+		e1000_fill_new_rx_descriptor(nic, next_tail);
 		
 		*tail_addr = e1000_inc_tail(*tail_addr, E1000_RX_PACKETS_COUNT);
@@ -1177,29 +1188,28 @@
 		
 		rx_descriptor = (e1000_rx_descriptor_t *)
-		    (e1000_data->rx_ring.virt +
-		    next_tail * sizeof(e1000_rx_descriptor_t));
+		    (e1000->rx_ring_virt + next_tail * sizeof(e1000_rx_descriptor_t));
 	}
 	
-	fibril_mutex_unlock(&e1000_data->rx_lock);
+	fibril_mutex_unlock(&e1000->rx_lock);
 }
 
 /** Enable E1000 interupts
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_enable_interrupts(e1000_t *e1000_data)
-{
-	E1000_REG_WRITE(e1000_data, E1000_IMS, ICR_RXT0);
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_enable_interrupts(e1000_t *e1000)
+{
+	E1000_REG_WRITE(e1000, E1000_IMS, ICR_RXT0);
 }
 
 /** Disable E1000 interupts
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_disable_interrupts(e1000_t *e1000_data)
-{
-	E1000_REG_WRITE(e1000_data, E1000_IMS, 0);
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_disable_interrupts(e1000_t *e1000)
+{
+	E1000_REG_WRITE(e1000, E1000_IMS, 0);
 }
 
@@ -1209,12 +1219,12 @@
  * and e1000_poll()
  *
- * @param nic_data NIC data
- * @param icr      ICR register value
- *
- */
-static void e1000_interrupt_handler_impl(nic_t *nic_data, uint32_t icr)
+ * @param nic NIC data
+ * @param icr ICR register value
+ *
+ */
+static void e1000_interrupt_handler_impl(nic_t *nic, uint32_t icr)
 {
 	if (icr & ICR_RXT0)
-		e1000_receive_packets(nic_data);
+		e1000_receive_packets(nic);
 }
 
@@ -1230,9 +1240,9 @@
 {
 	uint32_t icr = (uint32_t) IPC_GET_ARG2(*icall);
-	nic_t *nic_data = NIC_DATA_DEV(dev);
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
-	
-	e1000_interrupt_handler_impl(nic_data, icr);
-	e1000_enable_interrupts(e1000_data);
+	nic_t *nic = NIC_DATA_DEV(dev);
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
+	
+	e1000_interrupt_handler_impl(nic, icr);
+	e1000_enable_interrupts(e1000);
 }
 
@@ -1242,5 +1252,5 @@
  * structure.
  *
- * @param nic_data Driver data
+ * @param nic Driver data
  *
  * @return EOK if the handler was registered
@@ -1248,19 +1258,16 @@
  *
  */
-inline static int e1000_register_int_handler(nic_t *nic_data)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
+inline static int e1000_register_int_handler(nic_t *nic)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
 	
 	/* Lock the mutex in whole driver while working with global structure */
 	fibril_mutex_lock(&irq_reg_mutex);
 	
-	// FIXME: This is not supported in mainline
-	e1000_irq_code.cmds[0].addr =
-	    0xffff800000000000 + e1000_data->phys_reg_base + E1000_ICR;
-	e1000_irq_code.cmds[2].addr =
-	    0xffff800000000000 + e1000_data->phys_reg_base + E1000_IMC;
-	
-	int rc = register_interrupt_handler(nic_get_ddf_dev(nic_data),
-	    e1000_data->irq, e1000_interrupt_handler, &e1000_irq_code);
+	e1000_irq_code.cmds[0].addr = e1000->reg_base_virt + E1000_ICR;
+	e1000_irq_code.cmds[2].addr = e1000->reg_base_virt + E1000_IMC;
+	
+	int rc = register_interrupt_handler(nic_get_ddf_dev(nic),
+	    e1000->irq, e1000_interrupt_handler, &e1000_irq_code);
 	
 	fibril_mutex_unlock(&irq_reg_mutex);
@@ -1270,16 +1277,16 @@
 /** Force receiving all packets in the receive buffer
  *
- * @param nic_data NIC data
- *
- */
-static void e1000_poll(nic_t *nic_data)
-{
-	assert(nic_data);
-	
-	e1000_t *e1000_data = nic_get_specific(nic_data);
-	assert(e1000_data);
-	
-	uint32_t icr = E1000_REG_READ(e1000_data, E1000_ICR);
-	e1000_interrupt_handler_impl(nic_data, icr);
+ * @param nic NIC data
+ *
+ */
+static void e1000_poll(nic_t *nic)
+{
+	assert(nic);
+	
+	e1000_t *e1000 = nic_get_specific(nic);
+	assert(e1000);
+	
+	uint32_t icr = E1000_REG_READ(e1000, E1000_ICR);
+	e1000_interrupt_handler_impl(nic, icr);
 }
 
@@ -1305,25 +1312,25 @@
  *
  */
-static int e1000_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,
+static int e1000_poll_mode_change(nic_t *nic, nic_poll_mode_t mode,
     const struct timeval *period)
 {
-	assert(nic_data);
-	
-	e1000_t *e1000_data = nic_get_specific(nic_data);
-	assert(e1000_data);
+	assert(nic);
+	
+	e1000_t *e1000 = nic_get_specific(nic);
+	assert(e1000);
 	
 	switch (mode) {
 	case NIC_POLL_IMMEDIATE:
-		E1000_REG_WRITE(e1000_data, E1000_ITR, 0);
-		e1000_enable_interrupts(e1000_data);
+		E1000_REG_WRITE(e1000, E1000_ITR, 0);
+		e1000_enable_interrupts(e1000);
 		break;
 	case NIC_POLL_ON_DEMAND:
-		e1000_disable_interrupts(e1000_data);
+		e1000_disable_interrupts(e1000);
 		break;
 	case NIC_POLL_PERIODIC:
 		assert(period);
 		uint16_t itr_interval = e1000_calculate_itr_interval(period);
-		E1000_REG_WRITE(e1000_data, E1000_ITR, (uint32_t) itr_interval);
-		e1000_enable_interrupts(e1000_data);
+		E1000_REG_WRITE(e1000, E1000_ITR, (uint32_t) itr_interval);
+		e1000_enable_interrupts(e1000);
 		break;
 	default:
@@ -1336,22 +1343,22 @@
 /** Initialize receive registers
  *
- * @param e1000_data E1000 data structure
- *
- */
-static void e1000_initialize_rx_registers(e1000_t * e1000_data)
-{
-	E1000_REG_WRITE(e1000_data, E1000_RDLEN, E1000_RX_PACKETS_COUNT * 16);
-	E1000_REG_WRITE(e1000_data, E1000_RDH, 0);
+ * @param e1000 E1000 data structure
+ *
+ */
+static void e1000_initialize_rx_registers(e1000_t *e1000)
+{
+	E1000_REG_WRITE(e1000, E1000_RDLEN, E1000_RX_PACKETS_COUNT * 16);
+	E1000_REG_WRITE(e1000, E1000_RDH, 0);
 	
 	/* It is not posible to let HW use all descriptors */
-	E1000_REG_WRITE(e1000_data, E1000_RDT, E1000_RX_PACKETS_COUNT - 1);
+	E1000_REG_WRITE(e1000, E1000_RDT, E1000_RX_PACKETS_COUNT - 1);
 	
 	/* Set Broadcast Enable Bit */
-	E1000_REG_WRITE(e1000_data, E1000_RCTL, RCTL_BAM);
+	E1000_REG_WRITE(e1000, E1000_RCTL, RCTL_BAM);
 }
 
 /** Initialize receive structure
  *
- * @param nic_data NIC data
+ * @param nic NIC data
  *
  * @return EOK if succeed
@@ -1359,21 +1366,22 @@
  *
  */
-static int e1000_initialize_rx_structure(nic_t *nic_data)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
-	fibril_mutex_lock(&e1000_data->rx_lock);
-	
-	int rc = dmamem_map(&e1000_data->rx_ring,
-	    SIZE2PAGES(E1000_RX_PACKETS_COUNT * sizeof(e1000_rx_descriptor_t)),
-	    AS_AREA_READ | AS_AREA_WRITE, 0);
+static int e1000_initialize_rx_structure(nic_t *nic)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
+	fibril_mutex_lock(&e1000->rx_lock);
+	
+	int rc = dmamem_map_anonymous(
+	    E1000_RX_PACKETS_COUNT * sizeof(e1000_rx_descriptor_t),
+	    AS_AREA_READ | AS_AREA_WRITE, 0, &e1000->rx_ring_phys,
+	    &e1000->rx_ring_virt);
 	if (rc != EOK)
 		return rc;
 	
-	E1000_REG_WRITE(e1000_data, E1000_RDBAH,
-	    (uint32_t) (PTR_TO_U64(e1000_data->rx_ring.phys) >> 32));
-	E1000_REG_WRITE(e1000_data, E1000_RDBAL,
-	    (uint32_t) PTR_TO_U64(e1000_data->rx_ring.phys));
-	
-	e1000_data->rx_ring_packets =
+	E1000_REG_WRITE(e1000, E1000_RDBAH,
+	    (uint32_t) (PTR_TO_U64(e1000->rx_ring_phys) >> 32));
+	E1000_REG_WRITE(e1000, E1000_RDBAL,
+	    (uint32_t) PTR_TO_U64(e1000->rx_ring_phys));
+	
+	e1000->rx_ring_packets =
 	    malloc(E1000_RX_PACKETS_COUNT * sizeof(packet_t *));
 	// FIXME: Check return value
@@ -1383,9 +1391,9 @@
 	    offset < E1000_RX_PACKETS_COUNT;
 	    offset++)
-		e1000_fill_new_rx_descriptor(nic_data, offset);
-	
-	e1000_initialize_rx_registers(e1000_data);
-	
-	fibril_mutex_unlock(&e1000_data->rx_lock);
+		e1000_fill_new_rx_descriptor(nic, offset);
+	
+	e1000_initialize_rx_registers(e1000);
+	
+	fibril_mutex_unlock(&e1000->rx_lock);
 	return EOK;
 }
@@ -1393,10 +1401,10 @@
 /** Uninitialize receive structure
  *
- * @param nic_data NIC data
- *
- */
-static void e1000_uninitialize_rx_structure(nic_t *nic_data)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
+ * @param nic NIC data
+ *
+ */
+static void e1000_uninitialize_rx_structure(nic_t *nic)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
 	
 	/* Write descriptor */
@@ -1404,19 +1412,19 @@
 	    offset < E1000_RX_PACKETS_COUNT;
 	    offset++) {
-		packet_t *packet = *(e1000_data->rx_ring_packets + offset);
-		nic_dma_unlock_packet(packet);
-		nic_release_packet(nic_data, packet);
+		packet_t *packet = *(e1000->rx_ring_packets + offset);
+		nic_dma_unlock_packet(packet, E1000_MAX_RECEIVE_PACKET_SIZE);
+		nic_release_packet(nic, packet);
 	}
 	
-	free(e1000_data->rx_ring_packets);
-	dmamem_unmap(&e1000_data->rx_ring);
+	free(e1000->rx_ring_packets);
+	dmamem_unmap_anonymous(e1000->rx_ring_virt);
 }
 
 /** Clear receive descriptor ring
  *
- * @param e1000_data E1000 data
- *
- */
-static void e1000_clear_rx_ring(e1000_t * e1000_data)
+ * @param e1000 E1000 data
+ *
+ */
+static void e1000_clear_rx_ring(e1000_t *e1000)
 {
 	/* Write descriptor */
@@ -1424,41 +1432,41 @@
 	    offset < E1000_RX_PACKETS_COUNT;
 	    offset++)
-		e1000_clear_rx_descriptor(e1000_data, offset);
+		e1000_clear_rx_descriptor(e1000, offset);
 }
 
 /** Initialize filters
  *
- * @param e1000_data E1000 data
- *
- */
-static void e1000_initialize_filters(e1000_t *e1000_data)
+ * @param e1000 E1000 data
+ *
+ */
+static void e1000_initialize_filters(e1000_t *e1000)
 {
 	/* Initialize address filter */
-	e1000_data->unicast_ra_count = 0;
-	e1000_data->multicast_ra_count = 0;
-	e1000_clear_unicast_receive_addresses(e1000_data);
+	e1000->unicast_ra_count = 0;
+	e1000->multicast_ra_count = 0;
+	e1000_clear_unicast_receive_addresses(e1000);
 }
 
 /** Initialize VLAN
  *
- * @param e1000_data E1000 data
- *
- */
-static void e1000_initialize_vlan(e1000_t *e1000_data)
-{
-	e1000_data->vlan_tag_add = false;
+ * @param e1000 E1000 data
+ *
+ */
+static void e1000_initialize_vlan(e1000_t *e1000)
+{
+	e1000->vlan_tag_add = false;
 }
 
 /** Fill MAC address from EEPROM to RA[0] register
  *
- * @param e1000_data E1000 data
- *
- */
-static void e1000_fill_mac_from_eeprom(e1000_t *e1000_data)
+ * @param e1000 E1000 data
+ *
+ */
+static void e1000_fill_mac_from_eeprom(e1000_t *e1000)
 {
 	/* MAC address from eeprom to RA[0] */
 	nic_address_t address;
-	e1000_eeprom_get_address(e1000_data, &address);
-	e1000_write_receive_address(e1000_data, 0, &address, true);
+	e1000_eeprom_get_address(e1000, &address);
+	e1000_write_receive_address(e1000, 0, &address, true);
 }
 
@@ -1471,34 +1479,34 @@
  *
  */
-static void e1000_initialize_registers(e1000_t *e1000_data)
-{
-	E1000_REG_WRITE(e1000_data, E1000_ITR,
+static void e1000_initialize_registers(e1000_t *e1000)
+{
+	E1000_REG_WRITE(e1000, E1000_ITR,
 	    e1000_calculate_itr_interval_from_usecs(
 	    E1000_DEFAULT_INTERRUPT_INTERVAL_USEC));
-	E1000_REG_WRITE(e1000_data, E1000_FCAH, 0);
-	E1000_REG_WRITE(e1000_data, E1000_FCAL, 0);
-	E1000_REG_WRITE(e1000_data, E1000_FCT, 0);
-	E1000_REG_WRITE(e1000_data, E1000_FCTTV, 0);
-	E1000_REG_WRITE(e1000_data, E1000_VET, VET_VALUE);
-	E1000_REG_WRITE(e1000_data, E1000_CTRL, CTRL_ASDE);
+	E1000_REG_WRITE(e1000, E1000_FCAH, 0);
+	E1000_REG_WRITE(e1000, E1000_FCAL, 0);
+	E1000_REG_WRITE(e1000, E1000_FCT, 0);
+	E1000_REG_WRITE(e1000, E1000_FCTTV, 0);
+	E1000_REG_WRITE(e1000, E1000_VET, VET_VALUE);
+	E1000_REG_WRITE(e1000, E1000_CTRL, CTRL_ASDE);
 }
 
 /** Initialize transmit registers
  *
- * @param e1000_data E1000 data.
- *
- */
-static void e1000_initialize_tx_registers(e1000_t *e1000_data)
-{
-	E1000_REG_WRITE(e1000_data, E1000_TDLEN, E1000_TX_PACKETS_COUNT * 16);
-	E1000_REG_WRITE(e1000_data, E1000_TDH, 0);
-	E1000_REG_WRITE(e1000_data, E1000_TDT, 0);
-	
-	E1000_REG_WRITE(e1000_data, E1000_TIPG,
+ * @param e1000 E1000 data.
+ *
+ */
+static void e1000_initialize_tx_registers(e1000_t *e1000)
+{
+	E1000_REG_WRITE(e1000, E1000_TDLEN, E1000_TX_PACKETS_COUNT * 16);
+	E1000_REG_WRITE(e1000, E1000_TDH, 0);
+	E1000_REG_WRITE(e1000, E1000_TDT, 0);
+	
+	E1000_REG_WRITE(e1000, E1000_TIPG,
 	    10 << TIPG_IPGT_SHIFT |
 	    8 << TIPG_IPGR1_SHIFT |
 	    6 << TIPG_IPGR2_SHIFT);
 	
-	E1000_REG_WRITE(e1000_data, E1000_TCTL,
+	E1000_REG_WRITE(e1000, E1000_TCTL,
 	    0x0F << TCTL_CT_SHIFT /* Collision Threshold */ |
 	    0x40 << TCTL_COLD_SHIFT /* Collision Distance */ |
@@ -1508,32 +1516,33 @@
 /** Initialize transmit structure
  *
- * @param e1000_data E1000 data.
- *
- */
-static int e1000_initialize_tx_structure(e1000_t *e1000_data)
-{
-	fibril_mutex_lock(&e1000_data->tx_lock);
-	
-	int rc = dmamem_map(&e1000_data->tx_ring,
-	    SIZE2PAGES(E1000_TX_PACKETS_COUNT * sizeof(e1000_tx_descriptor_t)),
-	    AS_AREA_READ | AS_AREA_WRITE, 0);
+ * @param e1000 E1000 data.
+ *
+ */
+static int e1000_initialize_tx_structure(e1000_t *e1000)
+{
+	fibril_mutex_lock(&e1000->tx_lock);
+	
+	int rc = dmamem_map_anonymous(
+	    E1000_TX_PACKETS_COUNT * sizeof(e1000_tx_descriptor_t),
+	    AS_AREA_READ | AS_AREA_WRITE, 0, &e1000->tx_ring_phys,
+	    &e1000->tx_ring_virt);
 	if (rc != EOK)
 		return rc;
 	
-	bzero(e1000_data->tx_ring.virt,
+	bzero(e1000->tx_ring_virt,
 	    E1000_TX_PACKETS_COUNT * sizeof(e1000_tx_descriptor_t));
 	
-	E1000_REG_WRITE(e1000_data, E1000_TDBAH,
-	    (uint32_t) (PTR_TO_U64(e1000_data->tx_ring.phys) >> 32));
-	E1000_REG_WRITE(e1000_data, E1000_TDBAL,
-	    (uint32_t) PTR_TO_U64(e1000_data->tx_ring.phys));
-	
-	e1000_data->tx_ring_packets =
+	E1000_REG_WRITE(e1000, E1000_TDBAH,
+	    (uint32_t) (PTR_TO_U64(e1000->tx_ring_phys) >> 32));
+	E1000_REG_WRITE(e1000, E1000_TDBAL,
+	    (uint32_t) PTR_TO_U64(e1000->tx_ring_phys));
+	
+	e1000->tx_ring_packets =
 	    malloc(E1000_TX_PACKETS_COUNT * sizeof(packet_t *));
 	// FIXME: Check return value
 	
-	e1000_initialize_tx_registers(e1000_data);
-	
-	fibril_mutex_unlock(&e1000_data->tx_lock);
+	e1000_initialize_tx_registers(e1000);
+	
+	fibril_mutex_unlock(&e1000->tx_lock);
 	return EOK;
 }
@@ -1541,19 +1550,19 @@
 /** Uninitialize transmit structure
  *
- * @param nic_data NIC data
- *
- */
-static void e1000_uninitialize_tx_structure(e1000_t *e1000_data)
-{
-	free(e1000_data->tx_ring_packets);
-	dmamem_unmap(&e1000_data->tx_ring);
+ * @param nic NIC data
+ *
+ */
+static void e1000_uninitialize_tx_structure(e1000_t *e1000)
+{
+	free(e1000->tx_ring_packets);
+	dmamem_unmap_anonymous(e1000->tx_ring_virt);
 }
 
 /** Clear transmit descriptor ring
  *
- * @param nic_data NIC data
- *
- */
-static void e1000_clear_tx_ring(nic_t *nic_data)
+ * @param nic NIC data
+ *
+ */
+static void e1000_clear_tx_ring(nic_t *nic)
 {
 	/* Write descriptor */
@@ -1561,41 +1570,41 @@
 	    offset < E1000_TX_PACKETS_COUNT;
 	    offset++)
-		e1000_clear_tx_descriptor(nic_data, offset);
+		e1000_clear_tx_descriptor(nic, offset);
 }
 
 /** Enable transmit
  *
- * @param e1000_data E1000 data
- *
- */
-static void e1000_enable_tx(e1000_t *e1000_data)
+ * @param e1000 E1000 data
+ *
+ */
+static void e1000_enable_tx(e1000_t *e1000)
 {
 	/* Set Transmit Enable Bit */
-	E1000_REG_WRITE(e1000_data, E1000_TCTL,
-	    E1000_REG_READ(e1000_data, E1000_TCTL) | (TCTL_EN));
+	E1000_REG_WRITE(e1000, E1000_TCTL,
+	    E1000_REG_READ(e1000, E1000_TCTL) | (TCTL_EN));
 }
 
 /** Disable transmit
  *
- * @param e1000_data E1000 data
- *
- */
-static void e1000_disable_tx(e1000_t *e1000_data)
+ * @param e1000 E1000 data
+ *
+ */
+static void e1000_disable_tx(e1000_t *e1000)
 {
 	/* Clear Transmit Enable Bit */
-	E1000_REG_WRITE(e1000_data, E1000_TCTL,
-	    E1000_REG_READ(e1000_data, E1000_TCTL) & ~(TCTL_EN));
+	E1000_REG_WRITE(e1000, E1000_TCTL,
+	    E1000_REG_READ(e1000, E1000_TCTL) & ~(TCTL_EN));
 }
 
 /** Reset E1000 device
  *
- * @param e1000_data The E1000 data
- *
- */
-static int e1000_reset(nic_t *nic_data)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
-	
-	E1000_REG_WRITE(e1000_data, E1000_CTRL, CTRL_RST);
+ * @param e1000 The E1000 data
+ *
+ */
+static int e1000_reset(nic_t *nic)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
+	
+	E1000_REG_WRITE(e1000, E1000_CTRL, CTRL_RST);
 	
 	/* Wait for the reset */
@@ -1603,13 +1612,13 @@
 	
 	/* check if RST_BIT cleared */
-	if (E1000_REG_READ(e1000_data, E1000_CTRL) & (CTRL_RST))
+	if (E1000_REG_READ(e1000, E1000_CTRL) & (CTRL_RST))
 		return EINVAL;
 	
-	e1000_initialize_registers(e1000_data);
-	e1000_initialize_rx_registers(e1000_data);
-	e1000_initialize_tx_registers(e1000_data);
-	e1000_fill_mac_from_eeprom(e1000_data);
-	e1000_initialize_filters(e1000_data);
-	e1000_initialize_vlan(e1000_data);
+	e1000_initialize_registers(e1000);
+	e1000_initialize_rx_registers(e1000);
+	e1000_initialize_tx_registers(e1000);
+	e1000_fill_mac_from_eeprom(e1000);
+	e1000_initialize_filters(e1000);
+	e1000_initialize_vlan(e1000);
 	
 	return EOK;
@@ -1618,5 +1627,5 @@
 /** Activate the device to receive and transmit packets
  *
- * @param nic_data NIC driver data
+ * @param nic NIC driver data
  *
  * @return EOK if activated successfully
@@ -1624,31 +1633,31 @@
  *
  */
-static int e1000_on_activating(nic_t *nic_data)
-{
-	assert(nic_data);
-	
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
-	
-	fibril_mutex_lock(&e1000_data->rx_lock);
-	fibril_mutex_lock(&e1000_data->tx_lock);
-	fibril_mutex_lock(&e1000_data->ctrl_lock);
-	
-	e1000_enable_interrupts(e1000_data);
-	
-	nic_enable_interrupt(nic_data, e1000_data->irq);
-	
-	e1000_clear_rx_ring(e1000_data);
-	e1000_enable_rx(e1000_data);
-	
-	e1000_clear_tx_ring(nic_data);
-	e1000_enable_tx(e1000_data);
-	
-	uint32_t ctrl = E1000_REG_READ(e1000_data, E1000_CTRL);
+static int e1000_on_activating(nic_t *nic)
+{
+	assert(nic);
+	
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
+	
+	fibril_mutex_lock(&e1000->rx_lock);
+	fibril_mutex_lock(&e1000->tx_lock);
+	fibril_mutex_lock(&e1000->ctrl_lock);
+	
+	e1000_enable_interrupts(e1000);
+	
+	nic_enable_interrupt(nic, e1000->irq);
+	
+	e1000_clear_rx_ring(e1000);
+	e1000_enable_rx(e1000);
+	
+	e1000_clear_tx_ring(nic);
+	e1000_enable_tx(e1000);
+	
+	uint32_t ctrl = E1000_REG_READ(e1000, E1000_CTRL);
 	ctrl |= CTRL_SLU;
-	E1000_REG_WRITE(e1000_data, E1000_CTRL, ctrl);
-	
-	fibril_mutex_unlock(&e1000_data->ctrl_lock);
-	fibril_mutex_unlock(&e1000_data->tx_lock);
-	fibril_mutex_unlock(&e1000_data->rx_lock);
+	E1000_REG_WRITE(e1000, E1000_CTRL, ctrl);
+	
+	fibril_mutex_unlock(&e1000->ctrl_lock);
+	fibril_mutex_unlock(&e1000->tx_lock);
+	fibril_mutex_unlock(&e1000->rx_lock);
 	
 	return EOK;
@@ -1657,5 +1666,5 @@
 /** Callback for NIC_STATE_DOWN change
  *
- * @param nic_data NIC driver data
+ * @param nic NIC driver data
  *
  * @return EOK if succeed
@@ -1663,17 +1672,17 @@
  *
  */
-static int e1000_on_down_unlocked(nic_t *nic_data)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
-	
-	uint32_t ctrl = E1000_REG_READ(e1000_data, E1000_CTRL);
+static int e1000_on_down_unlocked(nic_t *nic)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
+	
+	uint32_t ctrl = E1000_REG_READ(e1000, E1000_CTRL);
 	ctrl &= ~CTRL_SLU;
-	E1000_REG_WRITE(e1000_data, E1000_CTRL, ctrl);
-	
-	e1000_disable_tx(e1000_data);
-	e1000_disable_rx(e1000_data);
-	
-	nic_disable_interrupt(nic_data, e1000_data->irq);
-	e1000_disable_interrupts(e1000_data);
+	E1000_REG_WRITE(e1000, E1000_CTRL, ctrl);
+	
+	e1000_disable_tx(e1000);
+	e1000_disable_rx(e1000);
+	
+	nic_disable_interrupt(nic, e1000->irq);
+	e1000_disable_interrupts(e1000);
 	
 	/*
@@ -1688,5 +1697,5 @@
 /** Callback for NIC_STATE_DOWN change
  *
- * @param nic_data NIC driver data
+ * @param nic NIC driver data
  *
  * @return EOK if succeed
@@ -1694,17 +1703,17 @@
  *
  */
-static int e1000_on_down(nic_t *nic_data)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
-	
-	fibril_mutex_lock(&e1000_data->rx_lock);
-	fibril_mutex_lock(&e1000_data->tx_lock);
-	fibril_mutex_lock(&e1000_data->ctrl_lock);
-	
-	int rc = e1000_on_down_unlocked(nic_data);
-	
-	fibril_mutex_unlock(&e1000_data->ctrl_lock);
-	fibril_mutex_unlock(&e1000_data->tx_lock);
-	fibril_mutex_unlock(&e1000_data->rx_lock);
+static int e1000_on_down(nic_t *nic)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
+	
+	fibril_mutex_lock(&e1000->rx_lock);
+	fibril_mutex_lock(&e1000->tx_lock);
+	fibril_mutex_lock(&e1000->ctrl_lock);
+	
+	int rc = e1000_on_down_unlocked(nic);
+	
+	fibril_mutex_unlock(&e1000->ctrl_lock);
+	fibril_mutex_unlock(&e1000->tx_lock);
+	fibril_mutex_unlock(&e1000->rx_lock);
 	
 	return rc;
@@ -1713,5 +1722,5 @@
 /** Callback for NIC_STATE_STOPPED change
  *
- * @param nic_data NIC driver data
+ * @param nic NIC driver data
  *
  * @return EOK if succeed
@@ -1719,19 +1728,19 @@
  *
  */
-static int e1000_on_stopping(nic_t *nic_data)
-{
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
-	
-	fibril_mutex_lock(&e1000_data->rx_lock);
-	fibril_mutex_lock(&e1000_data->tx_lock);
-	fibril_mutex_lock(&e1000_data->ctrl_lock);
-	
-	int rc = e1000_on_down_unlocked(nic_data);
+static int e1000_on_stopping(nic_t *nic)
+{
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
+	
+	fibril_mutex_lock(&e1000->rx_lock);
+	fibril_mutex_lock(&e1000->tx_lock);
+	fibril_mutex_lock(&e1000->ctrl_lock);
+	
+	int rc = e1000_on_down_unlocked(nic);
 	if (rc == EOK)
-		rc = e1000_reset(nic_data);
-	
-	fibril_mutex_unlock(&e1000_data->ctrl_lock);
-	fibril_mutex_unlock(&e1000_data->tx_lock);
-	fibril_mutex_unlock(&e1000_data->rx_lock);
+		rc = e1000_reset(nic);
+	
+	fibril_mutex_unlock(&e1000->ctrl_lock);
+	fibril_mutex_unlock(&e1000->tx_lock);
+	fibril_mutex_unlock(&e1000->rx_lock);
 	
 	return rc;
@@ -1748,31 +1757,31 @@
 	assert(!dev->driver_data);
 	
-	nic_t *nic_data = nic_create_and_bind(dev);
-	if (!nic_data)
+	nic_t *nic = nic_create_and_bind(dev);
+	if (!nic)
 		return NULL;
 	
-	e1000_t *e1000_data = malloc(sizeof(e1000_t));
-	if (!e1000_data) {
+	e1000_t *e1000 = malloc(sizeof(e1000_t));
+	if (!e1000) {
 		nic_unbind_and_destroy(dev);
 		return NULL;
 	}
 	
-	bzero(e1000_data, sizeof(e1000_t));
-	
-	nic_set_specific(nic_data, e1000_data);
-	nic_set_write_packet_handler(nic_data, e1000_write_packet);
-	nic_set_state_change_handlers(nic_data, e1000_on_activating,
+	bzero(e1000, sizeof(e1000_t));
+	
+	nic_set_specific(nic, e1000);
+	nic_set_write_packet_handler(nic, e1000_write_packet);
+	nic_set_state_change_handlers(nic, e1000_on_activating,
 	    e1000_on_down, e1000_on_stopping);
-	nic_set_filtering_change_handlers(nic_data,
+	nic_set_filtering_change_handlers(nic,
 	    e1000_on_unicast_mode_change, e1000_on_multicast_mode_change,
 	    e1000_on_broadcast_mode_change, NULL, e1000_on_vlan_mask_change);
-	nic_set_poll_handlers(nic_data, e1000_poll_mode_change, e1000_poll);
-	
-	fibril_mutex_initialize(&e1000_data->ctrl_lock);
-	fibril_mutex_initialize(&e1000_data->rx_lock);
-	fibril_mutex_initialize(&e1000_data->tx_lock);
-	fibril_mutex_initialize(&e1000_data->eeprom_lock);
-	
-	return e1000_data;
+	nic_set_poll_handlers(nic, e1000_poll_mode_change, e1000_poll);
+	
+	fibril_mutex_initialize(&e1000->ctrl_lock);
+	fibril_mutex_initialize(&e1000->rx_lock);
+	fibril_mutex_initialize(&e1000->tx_lock);
+	fibril_mutex_initialize(&e1000->eeprom_lock);
+	
+	return e1000;
 }
 
@@ -1825,11 +1834,11 @@
 	assert(dev->driver_data != NULL);
 	
-	e1000_t *e1000_data = DRIVER_DATA_DEV(dev);
+	e1000_t *e1000 = DRIVER_DATA_DEV(dev);
 	
 	if (hw_resources->irqs.count != 1)
 		return EINVAL;
 	
-	e1000_data->irq = hw_resources->irqs.irqs[0];
-	e1000_data->phys_reg_base =
+	e1000->irq = hw_resources->irqs.irqs[0];
+	e1000->reg_base_phys =
 	    MEMADDR_TO_PTR(hw_resources->mem_ranges.ranges[0].address);
 	
@@ -1878,6 +1887,6 @@
 {
 	/* Allocate driver data for the device. */
-	e1000_t *e1000_data = e1000_create_dev_data(dev);
-	if (e1000_data == NULL)
+	e1000_t *e1000 = e1000_create_dev_data(dev);
+	if (e1000 == NULL)
 		return ENOMEM;
 	
@@ -1890,5 +1899,5 @@
 	
 	rc = pci_config_space_read_16(dev->parent_sess, PCI_DEVICE_ID,
-	    &e1000_data->device_id);
+	    &e1000->device_id);
 	if (rc != EOK) {
 		e1000_dev_cleanup(dev);
@@ -1909,8 +1918,8 @@
 static int e1000_pio_enable(ddf_dev_t *dev)
 {
-	e1000_t *e1000_data = DRIVER_DATA_DEV(dev);
-	
-	int rc = pio_enable(e1000_data->phys_reg_base, 8 * PAGE_SIZE,
-	    &e1000_data->virt_reg_base);
+	e1000_t *e1000 = DRIVER_DATA_DEV(dev);
+	
+	int rc = pio_enable(e1000->reg_base_phys, 8 * PAGE_SIZE,
+	    &e1000->reg_base_virt);
 	if (rc != EOK)
 		return EADDRNOTAVAIL;
@@ -1934,6 +1943,6 @@
 	
 	/* Device initialization */
-	nic_t *nic_data = dev->driver_data;
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
+	nic_t *nic = dev->driver_data;
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
 	
 	/* Map registers */
@@ -1942,37 +1951,37 @@
 		goto err_destroy;
 	
-	e1000_initialize_registers(e1000_data);
-	rc = e1000_initialize_tx_structure(e1000_data);
+	e1000_initialize_registers(e1000);
+	rc = e1000_initialize_tx_structure(e1000);
 	if (rc != EOK)
 		goto err_pio;
 	
-	fibril_mutex_lock(&e1000_data->rx_lock);
-	
-	e1000_fill_mac_from_eeprom(e1000_data);
-	e1000_initialize_filters(e1000_data);
-	
-	fibril_mutex_unlock(&e1000_data->rx_lock);
-	
-	e1000_initialize_vlan(e1000_data);
-	
-	rc = nic_register_as_ddf_fun(nic_data, &e1000_dev_ops);
+	fibril_mutex_lock(&e1000->rx_lock);
+	
+	e1000_fill_mac_from_eeprom(e1000);
+	e1000_initialize_filters(e1000);
+	
+	fibril_mutex_unlock(&e1000->rx_lock);
+	
+	e1000_initialize_vlan(e1000);
+	
+	rc = nic_register_as_ddf_fun(nic, &e1000_dev_ops);
 	if (rc != EOK)
 		goto err_tx_structure;
 	
-	rc = e1000_register_int_handler(nic_data);
+	rc = e1000_register_int_handler(nic);
 	if (rc != EOK)
 		goto err_tx_structure;
 	
-	rc = nic_connect_to_services(nic_data);
+	rc = nic_connect_to_services(nic);
 	if (rc != EOK)
 		goto err_irq;
 	
-	rc = e1000_initialize_rx_structure(nic_data);
+	rc = e1000_initialize_rx_structure(nic);
 	if (rc != EOK)
 		goto err_irq;
 	
 	nic_address_t e1000_address;
-	e1000_get_address(e1000_data, &e1000_address);
-	rc = nic_report_address(nic_data, &e1000_address);
+	e1000_get_address(e1000, &e1000_address);
+	rc = nic_report_address(nic, &e1000_address);
 	if (rc != EOK)
 		goto err_rx_structure;
@@ -1981,5 +1990,5 @@
 	period.tv_sec = 0;
 	period.tv_usec = E1000_DEFAULT_INTERRUPT_INTERVAL_USEC;
-	rc = nic_report_poll_mode(nic_data, NIC_POLL_PERIODIC, &period);
+	rc = nic_report_poll_mode(nic, NIC_POLL_PERIODIC, &period);
 	if (rc != EOK)
 		goto err_rx_structure;
@@ -1988,9 +1997,9 @@
 	
 err_rx_structure:
-	e1000_uninitialize_rx_structure(nic_data);
+	e1000_uninitialize_rx_structure(nic);
 err_irq:
 	unregister_interrupt_handler(dev, DRIVER_DATA_DEV(dev)->irq);
 err_tx_structure:
-	e1000_uninitialize_tx_structure(e1000_data);
+	e1000_uninitialize_tx_structure(e1000);
 err_pio:
 	// TODO: e1000_pio_disable(dev);
@@ -2010,12 +2019,12 @@
  *
  */
-static uint16_t e1000_eeprom_read(e1000_t *e1000_data, uint8_t eeprom_address)
-{
-	fibril_mutex_lock(&e1000_data->eeprom_lock);
+static uint16_t e1000_eeprom_read(e1000_t *e1000, uint8_t eeprom_address)
+{
+	fibril_mutex_lock(&e1000->eeprom_lock);
 	
 	uint32_t eerd_done;
 	uint32_t eerd_address_offset;
 	
-	switch (e1000_data->device_id) {
+	switch (e1000->device_id) {
 	case 0x107c:
 	case 0x1013:
@@ -2040,13 +2049,13 @@
 	uint32_t write_data = EERD_START |
 	    (((uint32_t) eeprom_address) << eerd_address_offset);
-	E1000_REG_WRITE(e1000_data, E1000_EERD, write_data);
-	
-	uint32_t eerd = E1000_REG_READ(e1000_data, E1000_EERD);
+	E1000_REG_WRITE(e1000, E1000_EERD, write_data);
+	
+	uint32_t eerd = E1000_REG_READ(e1000, E1000_EERD);
 	while ((eerd & eerd_done) == 0) {
 		usleep(1);
-		eerd = E1000_REG_READ(e1000_data, E1000_EERD);
+		eerd = E1000_REG_READ(e1000, E1000_EERD);
 	}
 	
-	fibril_mutex_unlock(&e1000_data->eeprom_lock);
+	fibril_mutex_unlock(&e1000->eeprom_lock);
 	
 	return (uint16_t) (eerd >> EERD_DATA_OFFSET);
@@ -2063,7 +2072,7 @@
  *
  */
-static int e1000_get_address(e1000_t *e1000_data, nic_address_t *address)
-{
-	fibril_mutex_lock(&e1000_data->rx_lock);
+static int e1000_get_address(e1000_t *e1000, nic_address_t *address)
+{
+	fibril_mutex_lock(&e1000->rx_lock);
 	
 	uint8_t *mac0_dest = (uint8_t *) address->address;
@@ -2074,6 +2083,6 @@
 	uint8_t *mac5_dest = (uint8_t *) address->address + 5;
 	
-	uint32_t rah = E1000_REG_READ(e1000_data, E1000_RAH_ARRAY(0));
-	uint32_t ral = E1000_REG_READ(e1000_data, E1000_RAL_ARRAY(0));
+	uint32_t rah = E1000_REG_READ(e1000, E1000_RAH_ARRAY(0));
+	uint32_t ral = E1000_REG_READ(e1000, E1000_RAL_ARRAY(0));
 	
 	*mac0_dest = (uint8_t) ral;
@@ -2084,5 +2093,5 @@
 	*mac5_dest = (uint8_t) (rah >> 8);
 	
-	fibril_mutex_unlock(&e1000_data->rx_lock);
+	fibril_mutex_unlock(&e1000->rx_lock);
 	return EOK;
 };
@@ -2098,21 +2107,21 @@
 static int e1000_set_addr(ddf_fun_t *dev, const nic_address_t *addr)
 {
-	nic_t *nic_data = NIC_DATA_DEV(dev);
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
-	
-	fibril_mutex_lock(&e1000_data->rx_lock);
-	fibril_mutex_lock(&e1000_data->tx_lock);
-	
-	int rc = nic_report_address(nic_data, addr);
+	nic_t *nic = NIC_DATA_DEV(dev);
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
+	
+	fibril_mutex_lock(&e1000->rx_lock);
+	fibril_mutex_lock(&e1000->tx_lock);
+	
+	int rc = nic_report_address(nic, addr);
 	if (rc == EOK)
-		e1000_write_receive_address(e1000_data, 0, addr, false);
-	
-	fibril_mutex_unlock(&e1000_data->tx_lock);
-	fibril_mutex_unlock(&e1000_data->rx_lock);
+		e1000_write_receive_address(e1000, 0, addr, false);
+	
+	fibril_mutex_unlock(&e1000->tx_lock);
+	fibril_mutex_unlock(&e1000->rx_lock);
 	
 	return rc;
 }
 
-static void e1000_eeprom_get_address(e1000_t *e1000_data,
+static void e1000_eeprom_get_address(e1000_t *e1000,
     nic_address_t *address)
 {
@@ -2121,13 +2130,13 @@
 	uint16_t *mac4_dest = (uint16_t *) (address->address + 4);
 	
-	*mac0_dest = e1000_eeprom_read(e1000_data, 0);
-	*mac2_dest = e1000_eeprom_read(e1000_data, 1);
-	*mac4_dest = e1000_eeprom_read(e1000_data, 2);
+	*mac0_dest = e1000_eeprom_read(e1000, 0);
+	*mac2_dest = e1000_eeprom_read(e1000, 1);
+	*mac4_dest = e1000_eeprom_read(e1000, 2);
 }
 
 /** Send packet
  *
- * @param nic_data NIC driver data structure
- * @param packet   Packet to send
+ * @param nic    NIC driver data structure
+ * @param packet Packet to send
  *
  * @return EOK if succeed
@@ -2135,14 +2144,14 @@
  *
  */
-static void e1000_write_packet(nic_t *nic_data, packet_t *packet)
-{
-	assert(nic_data);
-	
-	e1000_t *e1000_data = DRIVER_DATA_NIC(nic_data);
-	fibril_mutex_lock(&e1000_data->tx_lock);
-	
-	uint32_t tdt = E1000_REG_READ(e1000_data, E1000_TDT);
+static void e1000_write_packet(nic_t *nic, packet_t *packet)
+{
+	assert(nic);
+	
+	e1000_t *e1000 = DRIVER_DATA_NIC(nic);
+	fibril_mutex_lock(&e1000->tx_lock);
+	
+	uint32_t tdt = E1000_REG_READ(e1000, E1000_TDT);
 	e1000_tx_descriptor_t *tx_descriptor_addr = (e1000_tx_descriptor_t *)
-	    (e1000_data->tx_ring.virt + tdt * sizeof(e1000_tx_descriptor_t));
+	    (e1000->tx_ring_virt + tdt * sizeof(e1000_tx_descriptor_t));
 	
 	bool descriptor_available = false;
@@ -2155,8 +2164,9 @@
 	if (tx_descriptor_addr->status & TXDESCRIPTOR_STATUS_DD) {
 		descriptor_available = true;
-		packet_t *old_packet = *(e1000_data->tx_ring_packets + tdt);
+		packet_t *old_packet = *(e1000->tx_ring_packets + tdt);
 		if (old_packet) {
-			nic_dma_unlock_packet(old_packet);
-			nic_release_packet(nic_data, old_packet);
+			size_t old_packet_size = packet_get_data_length(old_packet);
+			nic_dma_unlock_packet(old_packet, old_packet_size);
+			nic_release_packet(nic, old_packet);
 		}
 	}
@@ -2164,5 +2174,5 @@
 	if (!descriptor_available) {
 		/* Packet lost */
-		fibril_mutex_unlock(&e1000_data->tx_lock);
+		fibril_mutex_unlock(&e1000->tx_lock);
 		return;
 	}
@@ -2170,14 +2180,15 @@
 	size_t packet_size = packet_get_data_length(packet);
 	
-	void *phys_addr = nic_dma_lock_packet(packet);
-	if (!phys_addr) {
-		fibril_mutex_unlock(&e1000_data->tx_lock);
+	void *phys;
+	int rc = nic_dma_lock_packet(packet, packet_size, &phys);
+	if (rc != EOK) {
+		fibril_mutex_unlock(&e1000->tx_lock);
 		return;
 	}
 	
-	*(e1000_data->tx_ring_packets + tdt) = packet;
+	*(e1000->tx_ring_packets + tdt) = packet;
 	
 	tx_descriptor_addr->phys_addr =
-	    PTR_TO_U64(phys_addr + packet->data_start);
+	    PTR_TO_U64(phys + packet->data_start);
 	tx_descriptor_addr->length = packet_size;
 	
@@ -2192,6 +2203,6 @@
 	tx_descriptor_addr->checksum_offset = 0;
 	tx_descriptor_addr->status = 0;
-	if (e1000_data->vlan_tag_add) {
-		tx_descriptor_addr->special = e1000_data->vlan_tag;
+	if (e1000->vlan_tag_add) {
+		tx_descriptor_addr->special = e1000->vlan_tag;
 		tx_descriptor_addr->command |= TXDESCRIPTOR_COMMAND_VLE;
 	} else
@@ -2204,7 +2215,7 @@
 		tdt = 0;
 	
-	E1000_REG_WRITE(e1000_data, E1000_TDT, tdt);
-	
-	fibril_mutex_unlock(&e1000_data->tx_lock);
+	E1000_REG_WRITE(e1000, E1000_TDT, tdt);
+	
+	fibril_mutex_unlock(&e1000->tx_lock);
 }
 
@@ -2215,5 +2226,6 @@
 		return rc;
 	
-	nic_driver_implement(&e1000_driver_ops, &e1000_dev_ops, &e1000_nic_iface);
+	nic_driver_implement(&e1000_driver_ops, &e1000_dev_ops,
+	    &e1000_nic_iface);
 	return ddf_driver_main(&e1000_driver);
 }
