Lines Matching refs:ubufs
98 struct vhost_net_ubuf_ref *ubufs; member
125 struct vhost_net_ubuf_ref *ubufs; in vhost_net_ubuf_alloc() local
129 ubufs = kmalloc(sizeof(*ubufs), GFP_KERNEL); in vhost_net_ubuf_alloc()
130 if (!ubufs) in vhost_net_ubuf_alloc()
132 atomic_set(&ubufs->refcount, 1); in vhost_net_ubuf_alloc()
133 init_waitqueue_head(&ubufs->wait); in vhost_net_ubuf_alloc()
134 ubufs->vq = vq; in vhost_net_ubuf_alloc()
135 return ubufs; in vhost_net_ubuf_alloc()
138 static int vhost_net_ubuf_put(struct vhost_net_ubuf_ref *ubufs) in vhost_net_ubuf_put() argument
140 int r = atomic_sub_return(1, &ubufs->refcount); in vhost_net_ubuf_put()
142 wake_up(&ubufs->wait); in vhost_net_ubuf_put()
146 static void vhost_net_ubuf_put_and_wait(struct vhost_net_ubuf_ref *ubufs) in vhost_net_ubuf_put_and_wait() argument
148 vhost_net_ubuf_put(ubufs); in vhost_net_ubuf_put_and_wait()
149 wait_event(ubufs->wait, !atomic_read(&ubufs->refcount)); in vhost_net_ubuf_put_and_wait()
152 static void vhost_net_ubuf_put_wait_and_free(struct vhost_net_ubuf_ref *ubufs) in vhost_net_ubuf_put_wait_and_free() argument
154 vhost_net_ubuf_put_and_wait(ubufs); in vhost_net_ubuf_put_wait_and_free()
155 kfree(ubufs); in vhost_net_ubuf_put_wait_and_free()
198 n->vqs[i].ubufs = NULL; in vhost_net_vq_reset()
267 struct vhost_net_ubuf_ref *ubufs = ubuf->ctx; in vhost_zerocopy_callback() local
268 struct vhost_virtqueue *vq = ubufs->vq; in vhost_zerocopy_callback()
276 cnt = vhost_net_ubuf_put(ubufs); in vhost_zerocopy_callback()
310 struct vhost_net_ubuf_ref *uninitialized_var(ubufs); in handle_tx()
321 zcopy = nvq->ubufs; in handle_tx()
381 ubuf->ctx = nvq->ubufs; in handle_tx()
385 ubufs = nvq->ubufs; in handle_tx()
386 atomic_inc(&ubufs->refcount); in handle_tx()
390 ubufs = NULL; in handle_tx()
396 vhost_net_ubuf_put(ubufs); in handle_tx()
701 n->vqs[i].ubufs = NULL; in vhost_net_open()
774 if (n->vqs[VHOST_NET_VQ_TX].ubufs) { in vhost_net_flush()
779 vhost_net_ubuf_put_and_wait(n->vqs[VHOST_NET_VQ_TX].ubufs); in vhost_net_flush()
782 atomic_set(&n->vqs[VHOST_NET_VQ_TX].ubufs->refcount, 1); in vhost_net_flush()
882 struct vhost_net_ubuf_ref *ubufs, *oldubufs = NULL; in vhost_net_set_backend() local
912 ubufs = vhost_net_ubuf_alloc(vq, in vhost_net_set_backend()
914 if (IS_ERR(ubufs)) { in vhost_net_set_backend()
915 r = PTR_ERR(ubufs); in vhost_net_set_backend()
928 oldubufs = nvq->ubufs; in vhost_net_set_backend()
929 nvq->ubufs = ubufs; in vhost_net_set_backend()
956 if (ubufs) in vhost_net_set_backend()
957 vhost_net_ubuf_put_wait_and_free(ubufs); in vhost_net_set_backend()