From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f175.google.com (mail-pf0-f175.google.com [209.85.192.175]) by dpdk.org (Postfix) with ESMTP id 34227C314 for ; Tue, 16 Feb 2016 23:45:14 +0100 (CET) Received: by mail-pf0-f175.google.com with SMTP id e127so112749829pfe.3 for ; Tue, 16 Feb 2016 14:45:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bigswitch-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=30tT3u4T0L0uKFhGvnBVDFADRYJdQ+KHTwExhVBhOwg=; b=bBqUxcAZfrQ/0ULe6dn8h5J4OwWCK+t/UzMZ3iqvuTREQnGkt2J5c20OHcxnMrUenz oAu9hwDm+sf8PXA96XXmbN7N8j4B3r3OLkslcxmV4Lh7uEe23PvWbXzQuHLqHBgeP+Ng 1W+EfMZ0T/19jWlJTah//Ph1sVe0qFBw+/0qHTslcaStP6Q6d6vx1nD3IT8PRoXd5JfH NyKLNjvasfpweIgzd0n9mkcx1E9ntjrN81vs3/KcegGUd49JRjKxAq4NgwEG87NXDMuD 0jgJ0rv8chj8oEZvJIcbkZW99ssWRWkbYUs2OuGeYxdg5Gig52PWZq/tK4XFQ4Z3krpO BVmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=30tT3u4T0L0uKFhGvnBVDFADRYJdQ+KHTwExhVBhOwg=; b=O8FHUcCFEDvJqUmpAGADP06jfWTsJ2ZUwRkPzsdgFFkFbp6SUtZMSiF777SOoDUlnt whH/oyCRvA+pnzYFgAOiIFeA7ssBNGVImO9rrhlqgqbiwnxPon4Yp2aRtS8ZXh91asRa O8EjX0XjKBHIoXzOIJCotSU3J6CBAZ9bL9OO8DxTFaaeN2sTp1hHIkUqIROtgOOtLVTP p7SDvkjSvol6EwsY6wPNoKagQYPNKihuqFh29o2hWX/CNO+OmWyL3rcSFaB3PlKNh/JK yzMWRSq3DqBh0mOF2qsMvUmKO7igxsAv7n4w7y2gDUq2BPnDU+cngH1ETyAwLAgf11yW CZhA== X-Gm-Message-State: AG10YOQlCMWi4LI4k+FzKdl1rFRYmPcsxMiFbRGl2F+hRLPSzr2efU6tscbn7xb5PdKPpbLG X-Received: by 10.98.70.28 with SMTP id t28mr34486335pfa.110.1455662713546; Tue, 16 Feb 2016 14:45:13 -0800 (PST) Received: from rlane-work.eng.bigswitch.com ([173.227.38.50]) by smtp.gmail.com with ESMTPSA id e20sm48055075pfd.4.2016.02.16.14.45.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Feb 2016 14:45:12 -0800 (PST) From: Rich Lane X-Google-Original-From: Rich Lane To: dev@dpdk.org Date: Tue, 16 Feb 2016 14:45:04 -0800 Message-Id: <1455662704-49259-1-git-send-email-rlane@bigswitch.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455132428-46926-1-git-send-email-rlane@bigswitch.com> References: <1455132428-46926-1-git-send-email-rlane@bigswitch.com> Subject: [dpdk-dev] [PATCH v2] vhost: remove vhost_net_device_ops X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Feb 2016 22:45:14 -0000 The indirection is unnecessary because there is only one implementation of the vhost common code. Removing it makes the code more readable. Signed-off-by: Rich Lane --- v1->v2: - Fix long lines. examples/vhost_xen/virtio-net.h | 2 - lib/librte_vhost/vhost-net.h | 41 +++++------- lib/librte_vhost/vhost_cuse/vhost-net-cdev.c | 27 ++++---- lib/librte_vhost/vhost_cuse/virtio-net-cdev.c | 4 +- lib/librte_vhost/vhost_user/vhost-net-user.c | 23 +++---- lib/librte_vhost/vhost_user/virtio-net-user.c | 6 +- lib/librte_vhost/virtio-net.c | 94 +++++++++------------------ 7 files changed, 73 insertions(+), 124 deletions(-) diff --git a/examples/vhost_xen/virtio-net.h b/examples/vhost_xen/virtio-net.h index c8c5a7a..ab69726 100644 --- a/examples/vhost_xen/virtio-net.h +++ b/examples/vhost_xen/virtio-net.h @@ -110,6 +110,4 @@ struct virtio_net_device_ops { void (* destroy_device) (volatile struct virtio_net *); /* Remove device. */ }; -struct vhost_net_device_ops const * get_virtio_net_callbacks(void); - #endif diff --git a/lib/librte_vhost/vhost-net.h b/lib/librte_vhost/vhost-net.h index c69b60b..afa9829 100644 --- a/lib/librte_vhost/vhost-net.h +++ b/lib/librte_vhost/vhost-net.h @@ -43,8 +43,6 @@ #include "rte_virtio_net.h" -extern struct vhost_net_device_ops const *ops; - /* Macros for printing using RTE_LOG */ #define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1 #define RTE_LOGTYPE_VHOST_DATA RTE_LOGTYPE_USER1 @@ -85,34 +83,27 @@ struct vhost_device_ctx { uint64_t fh; /* Populated with fi->fh to track the device index. */ }; -/* - * Structure contains function pointers to be defined in virtio-net.c. These - * functions are called in CUSE context and are used to configure devices. - */ -struct vhost_net_device_ops { - int (*new_device)(struct vhost_device_ctx); - void (*destroy_device)(struct vhost_device_ctx); +int vhost_new_device(struct vhost_device_ctx); +void vhost_destroy_device(struct vhost_device_ctx); - void (*set_ifname)(struct vhost_device_ctx, - const char *if_name, unsigned int if_len); +void vhost_set_ifname(struct vhost_device_ctx, + const char *if_name, unsigned int if_len); - int (*get_features)(struct vhost_device_ctx, uint64_t *); - int (*set_features)(struct vhost_device_ctx, uint64_t *); +int vhost_get_features(struct vhost_device_ctx, uint64_t *); +int vhost_set_features(struct vhost_device_ctx, uint64_t *); - int (*set_vring_num)(struct vhost_device_ctx, struct vhost_vring_state *); - int (*set_vring_addr)(struct vhost_device_ctx, struct vhost_vring_addr *); - int (*set_vring_base)(struct vhost_device_ctx, struct vhost_vring_state *); - int (*get_vring_base)(struct vhost_device_ctx, uint32_t, struct vhost_vring_state *); +int vhost_set_vring_num(struct vhost_device_ctx, struct vhost_vring_state *); +int vhost_set_vring_addr(struct vhost_device_ctx, struct vhost_vring_addr *); +int vhost_set_vring_base(struct vhost_device_ctx, struct vhost_vring_state *); +int vhost_get_vring_base(struct vhost_device_ctx, + uint32_t, struct vhost_vring_state *); - int (*set_vring_kick)(struct vhost_device_ctx, struct vhost_vring_file *); - int (*set_vring_call)(struct vhost_device_ctx, struct vhost_vring_file *); +int vhost_set_vring_kick(struct vhost_device_ctx, struct vhost_vring_file *); +int vhost_set_vring_call(struct vhost_device_ctx, struct vhost_vring_file *); - int (*set_backend)(struct vhost_device_ctx, struct vhost_vring_file *); - - int (*set_owner)(struct vhost_device_ctx); - int (*reset_owner)(struct vhost_device_ctx); -}; +int vhost_set_backend(struct vhost_device_ctx, struct vhost_vring_file *); +int vhost_set_owner(struct vhost_device_ctx); +int vhost_reset_owner(struct vhost_device_ctx); -struct vhost_net_device_ops const *get_virtio_net_callbacks(void); #endif /* _VHOST_NET_CDEV_H_ */ diff --git a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c index ae7ad8d..c613e68 100644 --- a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c +++ b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c @@ -58,7 +58,6 @@ static const char cuse_device_name[] = "/dev/cuse"; static const char default_cdev[] = "vhost-net"; static struct fuse_session *session; -struct vhost_net_device_ops const *ops; /* * Returns vhost_device_ctx from given fuse_req_t. The index is populated later @@ -86,7 +85,7 @@ vhost_net_open(fuse_req_t req, struct fuse_file_info *fi) struct vhost_device_ctx ctx = fuse_req_to_vhost_ctx(req, fi); int err = 0; - err = ops->new_device(ctx); + err = vhost_new_device(ctx); if (err == -1) { fuse_reply_err(req, EPERM); return; @@ -108,7 +107,7 @@ vhost_net_release(fuse_req_t req, struct fuse_file_info *fi) int err = 0; struct vhost_device_ctx ctx = fuse_req_to_vhost_ctx(req, fi); - ops->destroy_device(ctx); + vhost_destroy_device(ctx); RTE_LOG(INFO, VHOST_CONFIG, "(%"PRIu64") Device released\n", ctx.fh); fuse_reply_err(req, err); } @@ -208,25 +207,25 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg, case VHOST_GET_FEATURES: LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") IOCTL: VHOST_GET_FEATURES\n", ctx.fh); - VHOST_IOCTL_W(uint64_t, features, ops->get_features); + VHOST_IOCTL_W(uint64_t, features, vhost_get_features); break; case VHOST_SET_FEATURES: LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") IOCTL: VHOST_SET_FEATURES\n", ctx.fh); - VHOST_IOCTL_R(uint64_t, features, ops->set_features); + VHOST_IOCTL_R(uint64_t, features, vhost_set_features); break; case VHOST_RESET_OWNER: LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") IOCTL: VHOST_RESET_OWNER\n", ctx.fh); - VHOST_IOCTL(ops->reset_owner); + VHOST_IOCTL(vhost_reset_owner); break; case VHOST_SET_OWNER: LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") IOCTL: VHOST_SET_OWNER\n", ctx.fh); - VHOST_IOCTL(ops->set_owner); + VHOST_IOCTL(vhost_set_owner); break; case VHOST_SET_MEM_TABLE: @@ -267,28 +266,28 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg, LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") IOCTL: VHOST_SET_VRING_NUM\n", ctx.fh); VHOST_IOCTL_R(struct vhost_vring_state, state, - ops->set_vring_num); + vhost_set_vring_num); break; case VHOST_SET_VRING_BASE: LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") IOCTL: VHOST_SET_VRING_BASE\n", ctx.fh); VHOST_IOCTL_R(struct vhost_vring_state, state, - ops->set_vring_base); + vhost_set_vring_base); break; case VHOST_GET_VRING_BASE: LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") IOCTL: VHOST_GET_VRING_BASE\n", ctx.fh); VHOST_IOCTL_RW(uint32_t, index, - struct vhost_vring_state, state, ops->get_vring_base); + struct vhost_vring_state, state, vhost_get_vring_base); break; case VHOST_SET_VRING_ADDR: LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") IOCTL: VHOST_SET_VRING_ADDR\n", ctx.fh); VHOST_IOCTL_R(struct vhost_vring_addr, addr, - ops->set_vring_addr); + vhost_set_vring_addr); break; case VHOST_SET_VRING_KICK: @@ -316,10 +315,10 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg, } file.fd = fd; if (cmd == VHOST_SET_VRING_KICK) { - result = ops->set_vring_kick(ctx, &file); + result = vhost_set_vring_kick(ctx, &file); fuse_reply_ioctl(req, result, NULL, 0); } else { - result = ops->set_vring_call(ctx, &file); + result = vhost_set_vring_call(ctx, &file); fuse_reply_ioctl(req, result, NULL, 0); } } @@ -397,8 +396,6 @@ rte_vhost_driver_register(const char *dev_name) cuse_info.dev_info_argv = device_argv; cuse_info.flags = CUSE_UNRESTRICTED_IOCTL; - ops = get_virtio_net_callbacks(); - session = cuse_lowlevel_setup(3, fuse_argv, &cuse_info, &vhost_net_ops, 0, NULL); if (session == NULL) diff --git a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c index ae2c3fa..2d3a4da 100644 --- a/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c +++ b/lib/librte_vhost/vhost_cuse/virtio-net-cdev.c @@ -399,7 +399,7 @@ get_ifname(struct vhost_device_ctx ctx, struct virtio_net *dev, int tap_fd, int if (ret >= 0) { ifr_size = strnlen(ifr.ifr_name, sizeof(ifr.ifr_name)); - ops->set_ifname(ctx, ifr.ifr_name, ifr_size); + vhost_set_ifname(ctx, ifr.ifr_name, ifr_size); } else RTE_LOG(ERR, VHOST_CONFIG, "(%"PRIu64") TUNGETIFF ioctl failed\n", @@ -419,5 +419,5 @@ int cuse_set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file) if (!(dev->flags & VIRTIO_DEV_RUNNING) && file->fd != VIRTIO_DEV_STOPPED) get_ifname(ctx, dev, file->fd, ctx.pid); - return ops->set_backend(ctx, file); + return vhost_set_backend(ctx, file); } diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c b/lib/librte_vhost/vhost_user/vhost-net-user.c index 8b7a448..da322d9 100644 --- a/lib/librte_vhost/vhost_user/vhost-net-user.c +++ b/lib/librte_vhost/vhost_user/vhost-net-user.c @@ -55,7 +55,6 @@ static void vserver_new_vq_conn(int fd, void *data, int *remove); static void vserver_message_handler(int fd, void *dat, int *remove); -struct vhost_net_device_ops const *ops; struct connfd_ctx { struct vhost_server *vserver; @@ -301,7 +300,7 @@ vserver_new_vq_conn(int fd, void *dat, __rte_unused int *remove) return; } - fh = ops->new_device(vdev_ctx); + fh = vhost_new_device(vdev_ctx); if (fh == -1) { free(ctx); close(conn_fd); @@ -310,7 +309,7 @@ vserver_new_vq_conn(int fd, void *dat, __rte_unused int *remove) vdev_ctx.fh = fh; size = strnlen(vserver->path, PATH_MAX); - ops->set_ifname(vdev_ctx, vserver->path, + vhost_set_ifname(vdev_ctx, vserver->path, size); RTE_LOG(INFO, VHOST_CONFIG, "new device, handle is %d\n", fh); @@ -348,7 +347,7 @@ vserver_message_handler(int connfd, void *dat, int *remove) *remove = 1; free(cfd_ctx); user_destroy_device(ctx); - ops->destroy_device(ctx); + vhost_destroy_device(ctx); return; } @@ -357,14 +356,14 @@ vserver_message_handler(int connfd, void *dat, int *remove) vhost_message_str[msg.request]); switch (msg.request) { case VHOST_USER_GET_FEATURES: - ret = ops->get_features(ctx, &features); + ret = vhost_get_features(ctx, &features); msg.payload.u64 = features; msg.size = sizeof(msg.payload.u64); send_vhost_message(connfd, &msg); break; case VHOST_USER_SET_FEATURES: features = msg.payload.u64; - ops->set_features(ctx, &features); + vhost_set_features(ctx, &features); break; case VHOST_USER_GET_PROTOCOL_FEATURES: @@ -377,10 +376,10 @@ vserver_message_handler(int connfd, void *dat, int *remove) break; case VHOST_USER_SET_OWNER: - ops->set_owner(ctx); + vhost_set_owner(ctx); break; case VHOST_USER_RESET_OWNER: - ops->reset_owner(ctx); + vhost_reset_owner(ctx); break; case VHOST_USER_SET_MEM_TABLE: @@ -397,13 +396,13 @@ vserver_message_handler(int connfd, void *dat, int *remove) break; case VHOST_USER_SET_VRING_NUM: - ops->set_vring_num(ctx, &msg.payload.state); + vhost_set_vring_num(ctx, &msg.payload.state); break; case VHOST_USER_SET_VRING_ADDR: - ops->set_vring_addr(ctx, &msg.payload.addr); + vhost_set_vring_addr(ctx, &msg.payload.addr); break; case VHOST_USER_SET_VRING_BASE: - ops->set_vring_base(ctx, &msg.payload.state); + vhost_set_vring_base(ctx, &msg.payload.state); break; case VHOST_USER_GET_VRING_BASE: @@ -450,8 +449,6 @@ rte_vhost_driver_register(const char *path) struct vhost_server *vserver; pthread_mutex_lock(&g_vhost_server.server_mutex); - if (ops == NULL) - ops = get_virtio_net_callbacks(); if (g_vhost_server.vserver_cnt == MAX_VHOST_SERVER) { RTE_LOG(ERR, VHOST_CONFIG, diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c index 2934d1c..fa74c39 100644 --- a/lib/librte_vhost/vhost_user/virtio-net-user.c +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c @@ -253,7 +253,7 @@ user_set_vring_call(struct vhost_device_ctx ctx, struct VhostUserMsg *pmsg) file.fd = pmsg->fds[0]; RTE_LOG(INFO, VHOST_CONFIG, "vring call idx:%d file:%d\n", file.index, file.fd); - ops->set_vring_call(ctx, &file); + vhost_set_vring_call(ctx, &file); } @@ -274,7 +274,7 @@ user_set_vring_kick(struct vhost_device_ctx ctx, struct VhostUserMsg *pmsg) file.fd = pmsg->fds[0]; RTE_LOG(INFO, VHOST_CONFIG, "vring kick idx:%d file:%d\n", file.index, file.fd); - ops->set_vring_kick(ctx, &file); + vhost_set_vring_kick(ctx, &file); if (virtio_is_ready(dev) && !(dev->flags & VIRTIO_DEV_RUNNING)) @@ -297,7 +297,7 @@ user_get_vring_base(struct vhost_device_ctx ctx, notify_ops->destroy_device(dev); /* Here we are safe to get the last used index */ - ops->get_vring_base(ctx, state->index, state); + vhost_get_vring_base(ctx, state->index, state); RTE_LOG(INFO, VHOST_CONFIG, "vring base idx:%d file:%d\n", state->index, state->num); diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index de78a0f..ddbd47f 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -348,8 +348,8 @@ reset_device(struct virtio_net *dev) * initialised and a new entry is added to the device configuration linked * list. */ -static int -new_device(struct vhost_device_ctx ctx) +int +vhost_new_device(struct vhost_device_ctx ctx) { struct virtio_net_config_ll *new_ll_dev; @@ -374,8 +374,8 @@ new_device(struct vhost_device_ctx ctx) * Function is called from the CUSE release function. This function will * cleanup the device and remove it from device configuration linked list. */ -static void -destroy_device(struct vhost_device_ctx ctx) +void +vhost_destroy_device(struct vhost_device_ctx ctx) { struct virtio_net_config_ll *ll_dev_cur_ctx, *ll_dev_last = NULL; struct virtio_net_config_ll *ll_dev_cur = ll_root; @@ -403,8 +403,8 @@ destroy_device(struct vhost_device_ctx ctx) } } -static void -set_ifname(struct vhost_device_ctx ctx, +void +vhost_set_ifname(struct vhost_device_ctx ctx, const char *if_name, unsigned int if_len) { struct virtio_net *dev; @@ -426,8 +426,8 @@ set_ifname(struct vhost_device_ctx ctx, * This function just returns success at the moment unless * the device hasn't been initialised. */ -static int -set_owner(struct vhost_device_ctx ctx) +int +vhost_set_owner(struct vhost_device_ctx ctx) { struct virtio_net *dev; @@ -441,8 +441,8 @@ set_owner(struct vhost_device_ctx ctx) /* * Called from CUSE IOCTL: VHOST_RESET_OWNER */ -static int -reset_owner(struct vhost_device_ctx ctx) +int +vhost_reset_owner(struct vhost_device_ctx ctx) { struct virtio_net *dev; @@ -462,8 +462,8 @@ reset_owner(struct vhost_device_ctx ctx) * Called from CUSE IOCTL: VHOST_GET_FEATURES * The features that we support are requested. */ -static int -get_features(struct vhost_device_ctx ctx, uint64_t *pu) +int +vhost_get_features(struct vhost_device_ctx ctx, uint64_t *pu) { struct virtio_net *dev; @@ -480,8 +480,8 @@ get_features(struct vhost_device_ctx ctx, uint64_t *pu) * Called from CUSE IOCTL: VHOST_SET_FEATURES * We receive the negotiated features supported by us and the virtio device. */ -static int -set_features(struct vhost_device_ctx ctx, uint64_t *pu) +int +vhost_set_features(struct vhost_device_ctx ctx, uint64_t *pu) { struct virtio_net *dev; uint16_t vhost_hlen; @@ -520,8 +520,9 @@ set_features(struct vhost_device_ctx ctx, uint64_t *pu) * Called from CUSE IOCTL: VHOST_SET_VRING_NUM * The virtio device sends us the size of the descriptor ring. */ -static int -set_vring_num(struct vhost_device_ctx ctx, struct vhost_vring_state *state) +int +vhost_set_vring_num(struct vhost_device_ctx ctx, + struct vhost_vring_state *state) { struct virtio_net *dev; @@ -622,8 +623,8 @@ numa_realloc(struct virtio_net *dev, int index __rte_unused) * The virtio device sends us the desc, used and avail ring addresses. * This function then converts these to our address space. */ -static int -set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr) +int +vhost_set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr) { struct virtio_net *dev; struct vhost_virtqueue *vq; @@ -680,8 +681,9 @@ set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr) * Called from CUSE IOCTL: VHOST_SET_VRING_BASE * The virtio device sends us the available ring last used index. */ -static int -set_vring_base(struct vhost_device_ctx ctx, struct vhost_vring_state *state) +int +vhost_set_vring_base(struct vhost_device_ctx ctx, + struct vhost_vring_state *state) { struct virtio_net *dev; @@ -700,8 +702,8 @@ set_vring_base(struct vhost_device_ctx ctx, struct vhost_vring_state *state) * Called from CUSE IOCTL: VHOST_GET_VRING_BASE * We send the virtio device our available ring last used index. */ -static int -get_vring_base(struct vhost_device_ctx ctx, uint32_t index, +int +vhost_get_vring_base(struct vhost_device_ctx ctx, uint32_t index, struct vhost_vring_state *state) { struct virtio_net *dev; @@ -723,8 +725,8 @@ get_vring_base(struct vhost_device_ctx ctx, uint32_t index, * The virtio device sends an eventfd to interrupt the guest. This fd gets * copied into our process space. */ -static int -set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file) +int +vhost_set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file) { struct virtio_net *dev; struct vhost_virtqueue *vq; @@ -760,8 +762,8 @@ set_vring_call(struct vhost_device_ctx ctx, struct vhost_vring_file *file) * The virtio device sends an eventfd that it can use to notify us. * This fd gets copied into our process space. */ -static int -set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file) +int +vhost_set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file) { struct virtio_net *dev; struct vhost_virtqueue *vq; @@ -790,8 +792,8 @@ set_vring_kick(struct vhost_device_ctx ctx, struct vhost_vring_file *file) * At that point we remove the device from the data core. * The device will still exist in the device configuration linked list. */ -static int -set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file) +int +vhost_set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file) { struct virtio_net *dev; @@ -818,42 +820,6 @@ set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file) return 0; } -/* - * Function pointers are set for the device operations to allow CUSE to call - * functions when an IOCTL, device_add or device_release is received. - */ -static const struct vhost_net_device_ops vhost_device_ops = { - .new_device = new_device, - .destroy_device = destroy_device, - - .set_ifname = set_ifname, - - .get_features = get_features, - .set_features = set_features, - - .set_vring_num = set_vring_num, - .set_vring_addr = set_vring_addr, - .set_vring_base = set_vring_base, - .get_vring_base = get_vring_base, - - .set_vring_kick = set_vring_kick, - .set_vring_call = set_vring_call, - - .set_backend = set_backend, - - .set_owner = set_owner, - .reset_owner = reset_owner, -}; - -/* - * Called by main to setup callbacks when registering CUSE device. - */ -struct vhost_net_device_ops const * -get_virtio_net_callbacks(void) -{ - return &vhost_device_ops; -} - int rte_vhost_enable_guest_notification(struct virtio_net *dev, uint16_t queue_id, int enable) { -- 1.9.1