X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flibrte_vhost%2Fvhost_cuse%2Fvhost-net-cdev.c;h=c613e68e8e231be96889542abc8915d2ee2aa565;hb=5d0c255e6b6c412e7cc687ea67af0f5f48e0f25e;hp=72609a3f8e2d963d7a1bcdeae9b3e2db3d04a5ff;hpb=9464a441601e8b2447373ce0dfcc31cc4ae409a5;p=dpdk.git diff --git a/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c b/lib/librte_vhost/vhost_cuse/vhost-net-cdev.c index 72609a3f8e..c613e68e8e 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); } @@ -196,31 +195,37 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg, case VHOST_NET_SET_BACKEND: LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") IOCTL: VHOST_NET_SET_BACKEND\n", ctx.fh); - VHOST_IOCTL_R(struct vhost_vring_file, file, ops->set_backend); + if (!in_buf) { + VHOST_IOCTL_RETRY(sizeof(file), 0); + break; + } + file = *(const struct vhost_vring_file *)in_buf; + result = cuse_set_backend(ctx, &file); + fuse_reply_ioctl(req, result, NULL, 0); break; 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: @@ -261,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: @@ -310,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); } } @@ -367,6 +372,9 @@ rte_vhost_driver_register(const char *dev_name) return -1; } + if (eventfd_init() < 0) + return -1; + /* * The device name is created. This is passed to QEMU so that it can * register the device with our application. @@ -388,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) @@ -398,6 +404,15 @@ rte_vhost_driver_register(const char *dev_name) return 0; } +/** + * An empty function for unregister + */ +int +rte_vhost_driver_unregister(const char *dev_name __rte_unused) +{ + return 0; +} + /** * The CUSE session is launched allowing the application to receive open, * release and ioctl calls.