/*-
* BSD LICENSE
- *
+ *
* Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
}
-static struct xen_guest *
+static struct xen_guest *
add_xen_guest(int32_t dom_id)
{
struct xen_guest *guest = NULL;
}
/*
- * Add entry containing a device to the device configuration linked list.
+ * Add entry containing a device to the device configuration linked list.
*/
static void
add_config_ll_entry(struct virtio_net_config_ll *new_ll_dev)
new_ll_dev->dev.device_fh = 0;
new_ll_dev->next = ll_dev;
ll_root = new_ll_dev;
- } else {
+ } else {
/* increment through the ll until we find un unused device_id,
* insert the device at that entry
*/
while ((ll_dev->next != NULL) && (ll_dev->dev.device_fh == (ll_dev->next->dev.device_fh - 1)))
ll_dev = ll_dev->next;
-
+
new_ll_dev->dev.device_fh = ll_dev->dev.device_fh + 1;
new_ll_dev->next = ll_dev->next;
ll_dev->next = new_ll_dev;
*/
static struct virtio_net_config_ll *
rm_config_ll_entry(struct virtio_net_config_ll *ll_dev, struct virtio_net_config_ll *ll_dev_last)
-{
+{
/* First remove the device and then clean it up. */
if (ll_dev == ll_root) {
ll_root = ll_dev->next;
/*
* Retrieves an entry from the devices configuration linked list.
*/
-static struct virtio_net_config_ll *
+static struct virtio_net_config_ll *
get_config_ll_entry(unsigned int virtio_idx, unsigned int dom_id)
{
struct virtio_net_config_ll *ll_dev = ll_root;
/* Loop through linked list until the dom_id is found. */
while (ll_dev != NULL) {
- if (ll_dev->dev.dom_id == dom_id && ll_dev->dev.virtio_idx == virtio_idx)
+ if (ll_dev->dev.dom_id == dom_id && ll_dev->dev.virtio_idx == virtio_idx)
return ll_dev;
ll_dev = ll_dev->next;
- }
+ }
return NULL;
}
-/*
- * Initialise all variables in device structure.
+/*
+ * Initialise all variables in device structure.
*/
static void
init_dev(struct virtio_net *dev)
uint64_t gpa;
uint32_t i;
- /* Setup device and virtqueues. */
+ /* Setup device and virtqueues. */
new_ll_dev = calloc(1, sizeof(struct virtio_net_config_ll));
virtqueue_rx = rte_zmalloc(NULL, sizeof(struct vhost_virtqueue), CACHE_LINE_SIZE);
virtqueue_tx = rte_zmalloc(NULL, sizeof(struct vhost_virtqueue), CACHE_LINE_SIZE);
if (new_ll_dev == NULL || virtqueue_rx == NULL || virtqueue_tx == NULL)
goto err;
- new_ll_dev->dev.virtqueue_rx = virtqueue_rx;
+ new_ll_dev->dev.virtqueue_rx = virtqueue_rx;
new_ll_dev->dev.virtqueue_tx = virtqueue_tx;
new_ll_dev->dev.dom_id = guest->dom_id;
new_ll_dev->dev.virtio_idx = virtio_idx;
new_ll_dev->dev.mem = malloc(sizeof(struct virtio_memory) + sizeof(struct virtio_memory_regions) * MAX_XENVIRT_MEMPOOL);
new_ll_dev->dev.mem->nregions = guest->pool_num;
for (i = 0; i < guest->pool_num; i++) {
- gpa = new_ll_dev->dev.mem->regions[i].guest_phys_address = (uint64_t)guest->mempool[i].gva;
+ gpa = new_ll_dev->dev.mem->regions[i].guest_phys_address = (uint64_t)guest->mempool[i].gva;
new_ll_dev->dev.mem->regions[i].guest_phys_address_end = gpa + guest->mempool[i].mempfn_num * getpagesize();
new_ll_dev->dev.mem->regions[i].address_offset = (uint64_t)guest->mempool[i].hva - gpa;
}
/*
* This function will cleanup the device and remove it from device configuration linked list.
*/
-static void
+static void
destroy_device(unsigned int virtio_idx, unsigned int dom_id)
{
struct virtio_net_config_ll *ll_dev_cur_ctx, *ll_dev_last = NULL;
-static void
+static void
watch_unmap_event(void)
{
int i;
RTE_LOG(INFO, XENHOST, " #####%s: destroy guest (%d)\n", __func__, guest->dom_id);
destroy_guest(guest);
goto _find_next_remove;
- }
+ }
return;
}
virtio_monitor_loop(void)
{
char **vec;
- xs_transaction_t th;
+ xs_transaction_t th;
char *buf;
unsigned int len;
unsigned int dom_id;
if (buf) {
/* theres' some node for vhost existed */
- if (rte_strsplit(vec[XS_WATCH_PATH], strnlen(vec[XS_WATCH_PATH], PATH_MAX),
+ if (rte_strsplit(vec[XS_WATCH_PATH], strnlen(vec[XS_WATCH_PATH], PATH_MAX),
str_fld, _NUM_FLD, '/') == _NUM_FLD) {
if (strstr(str_fld[FLD_NODE], VIRTIO_START)) {
errno = 0;
}
}
- free(vec);
- }
+ free(vec);
+ }
return;
}
/*
* Register ops so that we can add/remove device to data core.
*/
-int
+int
init_virtio_xen(struct virtio_net_device_ops const *const ops)
{
notify_ops = ops;