+
/*
* This file is part of the Palacios Virtual Machine Monitor developed
* by the V3VEE Project with funding from the United States National
uint8_t mergeable_rx_bufs;
struct v3_timer * timer;
- struct vnet_thread * poll_thread;
-
struct nic_statistics stats;
struct v3_dev_net_ops * net_ops;
virtio_state->stats.rx_interrupts ++;
}
- V3_Print("Virtio Intr Line %d\n", virtio_state->pci_dev->config_header.intr_line);
-
if(txed > 0) {
V3_Net_Print(2, "Virtio Handle TX: txed pkts: %d, left %d\n", txed, left);
}
pfn, page_addr);
if(virtio->tx_notify == 0){
disable_cb(&virtio->tx_vq);
- vnet_thread_wakeup(virtio->poll_thread);
}
+ virtio->status = 1;
break;
case 2:
virtio_setup_queue(core, virtio,
static int virtio_poll(int quote, void * data){
struct virtio_net_state * virtio = (struct virtio_net_state *)data;
- return handle_pkt_tx(&(virtio->vm->cores[0]), virtio, quote);
+ if (virtio->status) {
+
+ return handle_pkt_tx(&(virtio->vm->cores[0]), virtio, quote);
+ }
+
+ return 0;
}
static int register_dev(struct virtio_dev_state * virtio,
return 0;
}
-
#define RATE_UPPER_THRESHOLD 10 /* 10000 pkts per second, around 100Mbits */
#define RATE_LOWER_THRESHOLD 1
#define PROFILE_PERIOD 10000 /*us*/
net_state->net_ops = ops;
net_state->backend_data = private_data;
net_state->virtio_dev = virtio;
- net_state->tx_notify = 0;
- net_state->rx_notify = 0;
+
+ net_state->tx_notify = 1;
+ net_state->rx_notify = 1;
net_state->timer = v3_add_timer(&(info->cores[0]),
- &timer_ops,net_state);
+ &timer_ops,net_state);
ops->recv = virtio_rx;
ops->poll = virtio_poll;
ops->config.fnt_mac = V3_Malloc(ETH_ALEN);
memcpy(ops->config.fnt_mac, virtio->mac, ETH_ALEN);
- net_state->status = 1;
-
return 0;
}
void * private_data;
- struct list_head node;\r
+ struct list_head node;
} __attribute__((packed));
flags = vnet_lock_irqsave(vnet_state.lock);
list_for_each_entry(route, &(vnet_state.routes), node) {
- V3_Print("v3_vnet_del_route, route idx: %d\n", route->idx);
+ Vnet_Print(0, "v3_vnet_del_route, route idx: %d\n", route->idx);
if(route->idx == route_idx){
list_del(&(route->node));
Vnet_Free(route);
int v3_vnet_add_dev(struct v3_vm_info * vm, uint8_t * mac,
- struct v3_vnet_dev_ops *ops, int quote, int poll_state,
+ struct v3_vnet_dev_ops * ops, int quote, int poll_state,
void * priv_data){
struct vnet_dev * new_dev = NULL;
unsigned long flags;
memcpy(new_dev->mac_addr, mac, 6);
new_dev->dev_ops.input = ops->input;
+ new_dev->dev_ops.poll = ops->poll;
new_dev->private_data = priv_data;
new_dev->vm = vm;
new_dev->dev_id = 0;
list_add(&(new_dev->node), &(vnet_state.devs));
new_dev->dev_id = ++ vnet_state.dev_idx;
vnet_state.num_devs ++;
+
+ if(new_dev->poll) {
+ v3_enqueue(vnet_state.poll_devs, (addr_t)new_dev);
+ }
+ } else {
+ PrintError("VNET/P: Device with the same MAC is already there\n");
}
vnet_unlock_irqrestore(vnet_state.lock, flags);
* that runs on multiple cores
* or it could be running on a dedicated side core
*/
-static int vnet_tx_flush(void *args){
+static int vnet_tx_flush(void * args){
struct vnet_dev * dev = NULL;
int ret;
Vnet_Print(0, "VNET/P Polling Thread Starting ....\n");
- /* we need thread sleep/wakeup in Palacios */
while(!vnet_thread_should_stop()){
dev = (struct vnet_dev *)v3_dequeue(vnet_state.poll_devs);
if(dev != NULL){
if(dev->poll && dev->dev_ops.poll != NULL){
ret = dev->dev_ops.poll(dev->vm, dev->quote, dev->private_data);
-
+
if (ret < 0){
- PrintDebug("VNET/P: poll from device %p error!\n", dev);
+ Vnet_Print(0, "VNET/P: poll from device %p error!\n", dev);
}
-
- v3_enqueue(vnet_state.poll_devs, (addr_t)dev);
}
+ v3_enqueue(vnet_state.poll_devs, (addr_t)dev);
}else { /* no device needs to be polled */
/* sleep here? */
Vnet_Yield();
return 0;
}
-
int v3_init_vnet() {
memset(&vnet_state, 0, sizeof(vnet_state));
vnet_state.poll_devs = v3_create_queue();
- vnet_state.pkt_flush_thread = vnet_start_thread(vnet_tx_flush, NULL, "vnetd");
+ vnet_state.pkt_flush_thread = vnet_start_thread(vnet_tx_flush, NULL, "vnetd-1");
Vnet_Debug("VNET/P is initiated\n");