#include <palacios/vm_guest.h>
#include <palacios/vmm_sprintf.h>
-#ifndef CONFIG_DEBUG_NE2K
+#ifndef V3_CONFIG_DEBUG_NE2K
#undef PrintDebug
#define PrintDebug(fmts, args...)
#endif
if (pci_dev == NULL){
v3_raise_virq(&(nic_state->vm->cores[0]), NE2K_DEFAULT_IRQ);
} else {
- v3_pci_raise_irq(nic_state->pci_bus, 0, nic_state->pci_dev);
+ v3_pci_raise_irq(nic_state->pci_bus, nic_state->pci_dev, 0);
}
- nic_state->statistics.interrupts ++;
+ nic_state->statistics.rx_interrupts ++;
PrintDebug("NE2000: Raise IRQ\n");
}
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
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
}
-static int pci_config_update(uint_t reg_num,
+static int pci_config_update(struct pci_device * pci_dev,
+ uint32_t reg_num,
void * src,
uint_t length,
void * private_data) {
}
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;
pci_dev = v3_pci_register_device(nic_state->pci_bus, PCI_STD_DEVICE, 0, -1, 0,
"NE2000", bars,
- pci_config_update, NULL, NULL, nic_state);
+ pci_config_update, NULL, NULL, NULL, nic_state);
if (pci_dev == NULL) {
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;
}
char * macstr = v3_cfg_val(cfg, "mac");
nic_state = (struct ne2k_state *)V3_Malloc(sizeof(struct ne2k_state));
+
+ if (!nic_state) {
+ PrintError("Cannot allocate in init\n");
+ return -1;
+ }
+
memset(nic_state, 0, sizeof(struct ne2k_state));
nic_state->pci_bus = pci_bus;