return vhost_va;
}
-
struct virtio_net *
-get_device(struct vhost_device_ctx ctx)
+get_device(int vid)
{
- struct virtio_net *dev = vhost_devices[ctx.vid];
+ struct virtio_net *dev = vhost_devices[vid];
if (unlikely(!dev)) {
RTE_LOG(ERR, VHOST_CONFIG,
- "(%d) device not found.\n", ctx.vid);
+ "(%d) device not found.\n", vid);
}
return dev;
* list.
*/
int
-vhost_new_device(struct vhost_device_ctx ctx)
+vhost_new_device(void)
{
struct virtio_net *dev;
int i;
dev = rte_zmalloc(NULL, sizeof(struct virtio_net), 0);
if (dev == NULL) {
RTE_LOG(ERR, VHOST_CONFIG,
- "(%d) failed to allocate memory for dev.\n", ctx.vid);
+ "Failed to allocate memory for new dev.\n");
return -1;
}
* cleanup the device and remove it from device configuration linked list.
*/
void
-vhost_destroy_device(struct vhost_device_ctx ctx)
+vhost_destroy_device(int vid)
{
- struct virtio_net *dev = get_device(ctx);
+ struct virtio_net *dev = get_device(vid);
if (dev == NULL)
return;
cleanup_device(dev, 1);
free_device(dev);
- vhost_devices[ctx.vid] = NULL;
+ vhost_devices[vid] = NULL;
}
void
-vhost_set_ifname(struct vhost_device_ctx ctx,
- const char *if_name, unsigned int if_len)
+vhost_set_ifname(int vid, const char *if_name, unsigned int if_len)
{
struct virtio_net *dev;
unsigned int len;
- dev = get_device(ctx);
+ dev = get_device(vid);
if (dev == NULL)
return;
* the device hasn't been initialised.
*/
int
-vhost_set_owner(struct vhost_device_ctx ctx)
+vhost_set_owner(int vid)
{
struct virtio_net *dev;
- dev = get_device(ctx);
+ dev = get_device(vid);
if (dev == NULL)
return -1;
* Called from CUSE IOCTL: VHOST_RESET_OWNER
*/
int
-vhost_reset_owner(struct vhost_device_ctx ctx)
+vhost_reset_owner(int vid)
{
struct virtio_net *dev;
- dev = get_device(ctx);
+ dev = get_device(vid);
if (dev == NULL)
return -1;
* The features that we support are requested.
*/
int
-vhost_get_features(struct vhost_device_ctx ctx, uint64_t *pu)
+vhost_get_features(int vid, uint64_t *pu)
{
struct virtio_net *dev;
- dev = get_device(ctx);
+ dev = get_device(vid);
if (dev == NULL)
return -1;
* We receive the negotiated features supported by us and the virtio device.
*/
int
-vhost_set_features(struct vhost_device_ctx ctx, uint64_t *pu)
+vhost_set_features(int vid, uint64_t *pu)
{
struct virtio_net *dev;
uint16_t vhost_hlen;
uint16_t i;
- dev = get_device(ctx);
+ dev = get_device(vid);
if (dev == NULL)
return -1;
if (*pu & ~VHOST_FEATURES)
* The virtio device sends us the size of the descriptor ring.
*/
int
-vhost_set_vring_num(struct vhost_device_ctx ctx,
- struct vhost_vring_state *state)
+vhost_set_vring_num(int vid, struct vhost_vring_state *state)
{
struct virtio_net *dev;
- dev = get_device(ctx);
+ dev = get_device(vid);
if (dev == NULL)
return -1;
* This function then converts these to our address space.
*/
int
-vhost_set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr)
+vhost_set_vring_addr(int vid, struct vhost_vring_addr *addr)
{
struct virtio_net *dev;
struct vhost_virtqueue *vq;
- dev = get_device(ctx);
+ dev = get_device(vid);
if ((dev == NULL) || (dev->mem == NULL))
return -1;
* The virtio device sends us the available ring last used index.
*/
int
-vhost_set_vring_base(struct vhost_device_ctx ctx,
- struct vhost_vring_state *state)
+vhost_set_vring_base(int vid, struct vhost_vring_state *state)
{
struct virtio_net *dev;
- dev = get_device(ctx);
+ dev = get_device(vid);
if (dev == NULL)
return -1;
* We send the virtio device our available ring last used index.
*/
int
-vhost_get_vring_base(struct vhost_device_ctx ctx, uint32_t index,
+vhost_get_vring_base(int vid, uint32_t index,
struct vhost_vring_state *state)
{
struct virtio_net *dev;
- dev = get_device(ctx);
+ dev = get_device(vid);
if (dev == NULL)
return -1;
* copied into our process space.
*/
int
-vhost_set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file)
+vhost_set_vring_call(int vid, struct vhost_vring_file *file)
{
struct virtio_net *dev;
struct vhost_virtqueue *vq;
uint32_t cur_qp_idx = file->index / VIRTIO_QNUM;
- dev = get_device(ctx);
+ dev = get_device(vid);
if (dev == NULL)
return -1;
* This fd gets copied into our process space.
*/
int
-vhost_set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file)
+vhost_set_vring_kick(int vid, struct vhost_vring_file *file)
{
struct virtio_net *dev;
struct vhost_virtqueue *vq;
- dev = get_device(ctx);
+ dev = get_device(vid);
if (dev == NULL)
return -1;
* The device will still exist in the device configuration linked list.
*/
int
-vhost_set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file)
+vhost_set_backend(int vid, struct vhost_vring_file *file)
{
struct virtio_net *dev;
- dev = get_device(ctx);
+ dev = get_device(vid);
if (dev == NULL)
return -1;