X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fne2k.c;h=b4796f70b128cc7f307139fa8621156e685be4a0;hb=e895aea7212e8cd9e1ba9555f3313fbf90f83d7f;hp=f17f31d3abd63e25683f3bfbe5ea88a32fa23cd2;hpb=06332b6b7f1c53db7afb674f0ad056d40b1f88cb;p=palacios.git diff --git a/palacios/src/devices/ne2k.c b/palacios/src/devices/ne2k.c index f17f31d..b4796f7 100644 --- a/palacios/src/devices/ne2k.c +++ b/palacios/src/devices/ne2k.c @@ -28,7 +28,7 @@ #include #include -#ifndef CONFIG_DEBUG_NE2K +#ifndef V3_CONFIG_DEBUG_NE2K #undef PrintDebug #define PrintDebug(fmts, args...) #endif @@ -43,8 +43,10 @@ #define NE2K_MEM_SIZE NE2K_PMEM_END #define NIC_REG_BASE_PORT 0xc100 /* Command register (for all pages) */ -#define NIC_DATA_PORT 0xc110 /* Data read/write port */ -#define NIC_RESET_PORT 0xc11f /* Reset port */ + +#define NE2K_CMD_OFFSET 0x00 +#define NE2K_DATA_OFFSET 0x10 +#define NE2K_RESET_OFFSET 0x1f /* Page 0 registers */ #define EN0_CLDALO 0x01 /* Low byte of current local dma addr RD */ @@ -335,7 +337,7 @@ static int ne2k_update_irq(struct ne2k_state * nic_state) { v3_pci_raise_irq(nic_state->pci_bus, 0, nic_state->pci_dev); } - nic_state->statistics.interrupts ++; + nic_state->statistics.rx_interrupts ++; PrintDebug("NE2000: Raise IRQ\n"); } @@ -345,7 +347,7 @@ static int ne2k_update_irq(struct ne2k_state * nic_state) { static int tx_one_pkt(struct ne2k_state * nic_state, uchar_t *pkt, uint32_t length) { -#ifdef CONFIG_DEBUG_NE2K +#ifdef V3_CONFIG_DEBUG_NE2K PrintDebug("NE2000: Send Packet:\n"); v3_hexdump(pkt, length, NULL, 0); #endif @@ -482,7 +484,7 @@ static int rx_one_pkt(struct ne2k_state * nic_state, const uchar_t * pkt, uint3 static int ne2k_rx(uint8_t * buf, uint32_t size, void * private_data){ struct ne2k_state * nic_state = (struct ne2k_state *)private_data; -#ifdef CONFIG_DEBUG_NE2K +#ifdef V3_CONFIG_DEBUG_NE2K PrintDebug("\nNe2k: Packet Received:\n"); v3_hexdump(buf, size, NULL, 0); #endif @@ -1033,16 +1035,16 @@ static int ne2k_pci_write(struct guest_info * core, int ret; switch (idx) { - case NIC_REG_BASE_PORT: + case NE2K_CMD_OFFSET: ret = ne2k_cmd_write(core, port, src, length, private_data); break; - case NIC_REG_BASE_PORT+1 ... NIC_REG_BASE_PORT+15: + case NE2K_CMD_OFFSET+1 ... NE2K_CMD_OFFSET+15: ret = ne2k_std_write(core, port, src, length, private_data); break; - case NIC_DATA_PORT: + case NE2K_DATA_OFFSET: ret = ne2k_data_write(core, port, src, length, private_data); break; - case NIC_RESET_PORT: + case NE2K_RESET_OFFSET: ret = ne2k_reset_port_write(core, port, src, length, private_data); break; @@ -1063,16 +1065,16 @@ static int ne2k_pci_read(struct guest_info * core, int ret; switch (idx) { - case NIC_REG_BASE_PORT: + case NE2K_CMD_OFFSET: ret = ne2k_cmd_read(core, port, dst, length, private_data); break; - case NIC_REG_BASE_PORT+1 ... NIC_REG_BASE_PORT+15: + case NE2K_CMD_OFFSET+1 ... NE2K_CMD_OFFSET+15: ret = ne2k_std_read(core, port, dst, length, private_data); break; - case NIC_DATA_PORT: + case NE2K_DATA_OFFSET: ret = ne2k_data_read(core, port, dst, length, private_data); break; - case NIC_RESET_PORT: + case NE2K_RESET_OFFSET: ret = ne2k_reset_port_read(core, port, dst, length, private_data); break; @@ -1113,7 +1115,7 @@ static int register_dev(struct ne2k_state * nic_state) } bars[0].type = PCI_BAR_IO; - bars[0].default_base_port = NIC_REG_BASE_PORT; + bars[0].default_base_port = -1; bars[0].num_ports = 256; bars[0].io_read = ne2k_pci_read; @@ -1151,8 +1153,8 @@ static int register_dev(struct ne2k_state * nic_state) v3_dev_hook_io(nic_state->dev, NIC_REG_BASE_PORT + i, &ne2k_std_read, &ne2k_std_write); } - v3_dev_hook_io(nic_state->dev, NIC_DATA_PORT, &ne2k_data_read, &ne2k_data_write); - v3_dev_hook_io(nic_state->dev, NIC_RESET_PORT, &ne2k_reset_port_read, &ne2k_reset_port_write); + v3_dev_hook_io(nic_state->dev, NIC_REG_BASE_PORT + NE2K_DATA_OFFSET, &ne2k_data_read, &ne2k_data_write); + v3_dev_hook_io(nic_state->dev, NIC_REG_BASE_PORT + NE2K_RESET_OFFSET, &ne2k_reset_port_read, &ne2k_reset_port_write); } @@ -1173,11 +1175,9 @@ static int connect_fn(struct v3_vm_info * info, nic_state->backend_data = private_data; ops->recv = ne2k_rx; - ops->poll = NULL; - ops->start_tx = NULL; - ops->stop_tx = NULL; - ops->frontend_data = nic_state; - memcpy(ops->fnt_mac, nic_state->mac, ETH_ALEN); + ops->poll = NULL; + ops->config.frontend_data = nic_state; + ops->config.fnt_mac = nic_state->mac; return 0; } @@ -1193,8 +1193,8 @@ static int ne2k_free(struct ne2k_state * nic_state) { v3_dev_unhook_io(nic_state->dev, NIC_REG_BASE_PORT + i); } - v3_dev_unhook_io(nic_state->dev, NIC_DATA_PORT); - v3_dev_unhook_io(nic_state->dev, NIC_RESET_PORT); + v3_dev_unhook_io(nic_state->dev, NIC_REG_BASE_PORT + NE2K_DATA_OFFSET); + v3_dev_unhook_io(nic_state->dev, NIC_REG_BASE_PORT + NE2K_RESET_OFFSET); }else { /* unregistered from PCI? */ }