Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Revised check for already-launched VM
[palacios.git] / palacios / src / devices / ne2k.c
index 939bd28..420bc79 100644 (file)
@@ -28,7 +28,7 @@
 #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
@@ -334,10 +334,10 @@ static int ne2k_update_irq(struct ne2k_state * nic_state) {
        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");
     }
@@ -347,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    
@@ -484,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    
@@ -1088,7 +1088,8 @@ static int ne2k_pci_read(struct guest_info * core,
 
 }
 
-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) {
@@ -1115,7 +1116,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;
@@ -1124,7 +1125,7 @@ static int register_dev(struct ne2k_state * nic_state)
 
        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) {
@@ -1175,11 +1176,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;
 }
@@ -1219,6 +1218,12 @@ static int ne2k_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
     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;