X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Flnx_virtio_nic.c;h=b6fd304265095fcf09e66e2288286608c6c74bce;hb=c80aaab03156ec020bd4a76688ff6d2544955bf3;hp=acbce0d6d784566d6496fc2287d52dbd4d83ff38;hpb=107d8f06c7083f58fc96d781efb0226edd82c7d9;p=palacios.git diff --git a/palacios/src/devices/lnx_virtio_nic.c b/palacios/src/devices/lnx_virtio_nic.c index acbce0d..b6fd304 100644 --- a/palacios/src/devices/lnx_virtio_nic.c +++ b/palacios/src/devices/lnx_virtio_nic.c @@ -173,7 +173,7 @@ pkt_tx(struct guest_info * core, return -ERR_VIRTIO_OTHER; } - return virtio->net_ops->send(buf, len, virtio->backend_data, NULL); + return virtio->net_ops->send(buf, len, virtio->backend_data); } @@ -237,7 +237,7 @@ static int handle_rx_kick(struct guest_info *core, flags = v3_lock_irqsave(virtio->rx_lock); virtio->net_ops->start_rx(virtio->backend_data); - disable_cb(&virtio->rx_vq); + //disable_cb(&virtio->rx_vq); v3_unlock_irqrestore(virtio->rx_lock, flags); @@ -375,7 +375,6 @@ static int virtio_io_write(struct guest_info *core, struct virtio_net_state * virtio = (struct virtio_net_state *)private_data; int port_idx = port % virtio->io_range_size; - PrintDebug("VIRTIO NIC %p Write for port %d (index=%d) len=%d, value=%x\n", private_data, port, port_idx, length, *(uint32_t *)src); @@ -399,11 +398,11 @@ static int virtio_io_write(struct guest_info *core, switch (queue_idx) { case 0: virtio_setup_queue(core, virtio, &virtio->rx_vq, pfn, page_addr); - disable_cb(&virtio->rx_vq); + //disable_cb(&virtio->rx_vq); break; case 1: virtio_setup_queue(core, virtio, &virtio->tx_vq, pfn, page_addr); - disable_cb(&virtio->tx_vq); + //disable_cb(&virtio->tx_vq); break; case 2: virtio_setup_queue(core, virtio, &virtio->ctrl_vq, pfn, page_addr); @@ -427,9 +426,7 @@ static int virtio_io_write(struct guest_info *core, uint16_t queue_idx = *(uint16_t *)src; if (queue_idx == 0){ handle_rx_kick(core, virtio); - PrintError("rx kick\n"); } else if (queue_idx == 1){ - PrintError("tx kick\n"); if (handle_pkt_tx(core, virtio) == -1) { PrintError("Could not handle NIC Notification\n"); return -1; @@ -559,6 +556,13 @@ static int virtio_rx(uint8_t * buf, uint32_t size, void * private_data) { int ret_val = -ERR_VIRTIO_OTHER; int raw = 1; +#ifndef CONFIG_DEBUG_VIRTIO_NET + { + PrintDebug("Virtio-NIC: virtio_rx: size: %d\n", size); + //v3_hexdump(buf, size, NULL, 0); + } +#endif + flags = v3_lock_irqsave(virtio->rx_lock); virtio->pkt_recv ++; @@ -650,9 +654,6 @@ exit: static struct v3_device_ops dev_ops = { .free = virtio_free, - .reset = NULL, - .start = NULL, - .stop = NULL, }; @@ -792,9 +793,9 @@ static int connect_fn(struct v3_vm_info * info, static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { struct vm_device * pci_bus = v3_find_dev(vm, v3_cfg_val(cfg, "bus")); struct virtio_dev_state * virtio_state = NULL; - char * name = v3_cfg_val(cfg, "name"); + char * dev_id = v3_cfg_val(cfg, "ID"); - PrintDebug("Virtio NIC: Initializing VIRTIO Network device: %s\n", name); + PrintDebug("Virtio NIC: Initializing VIRTIO Network device: %s\n", dev_id); if (pci_bus == NULL) { PrintError("Virtio NIC: VirtIO devices require a PCI Bus"); @@ -808,14 +809,17 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { virtio_state->pci_bus = pci_bus; virtio_state->vm = vm; - struct vm_device * dev = v3_allocate_device(name, &dev_ops, virtio_state); - if (v3_attach_device(vm, dev) == -1) { - PrintError("Virtio NIC: Could not attach device %s\n", name); + struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, virtio_state); + + if (dev == NULL) { + PrintError("Virtio NIC: Could not attach device %s\n", dev_id); + V3_Free(virtio_state); return -1; } - if (v3_dev_add_net_frontend(vm, name, connect_fn, (void *)virtio_state) == -1) { - PrintError("Virtio NIC: Could not register %s as net frontend\n", name); + if (v3_dev_add_net_frontend(vm, dev_id, connect_fn, (void *)virtio_state) == -1) { + PrintError("Virtio NIC: Could not register %s as net frontend\n", dev_id); + v3_remove_device(dev); return -1; }