Lines Matching refs:ubufs

124 	struct vhost_net_ubuf_ref *ubufs;  member
236 struct vhost_net_ubuf_ref *ubufs; in vhost_net_ubuf_alloc() local
240 ubufs = kmalloc(sizeof(*ubufs), GFP_KERNEL); in vhost_net_ubuf_alloc()
241 if (!ubufs) in vhost_net_ubuf_alloc()
243 atomic_set(&ubufs->refcount, 1); in vhost_net_ubuf_alloc()
244 init_waitqueue_head(&ubufs->wait); in vhost_net_ubuf_alloc()
245 ubufs->vq = vq; in vhost_net_ubuf_alloc()
246 return ubufs; in vhost_net_ubuf_alloc()
249 static int vhost_net_ubuf_put(struct vhost_net_ubuf_ref *ubufs) in vhost_net_ubuf_put() argument
251 int r = atomic_sub_return(1, &ubufs->refcount); in vhost_net_ubuf_put()
253 wake_up(&ubufs->wait); in vhost_net_ubuf_put()
257 static void vhost_net_ubuf_put_and_wait(struct vhost_net_ubuf_ref *ubufs) in vhost_net_ubuf_put_and_wait() argument
259 vhost_net_ubuf_put(ubufs); in vhost_net_ubuf_put_and_wait()
260 wait_event(ubufs->wait, !atomic_read(&ubufs->refcount)); in vhost_net_ubuf_put_and_wait()
263 static void vhost_net_ubuf_put_wait_and_free(struct vhost_net_ubuf_ref *ubufs) in vhost_net_ubuf_put_wait_and_free() argument
265 vhost_net_ubuf_put_and_wait(ubufs); in vhost_net_ubuf_put_wait_and_free()
266 kfree(ubufs); in vhost_net_ubuf_put_wait_and_free()
311 n->vqs[i].ubufs = NULL; in vhost_net_vq_reset()
387 struct vhost_net_ubuf_ref *ubufs = ubuf->ctx; in vhost_zerocopy_callback() local
388 struct vhost_virtqueue *vq = ubufs->vq; in vhost_zerocopy_callback()
396 cnt = vhost_net_ubuf_put(ubufs); in vhost_zerocopy_callback()
872 struct vhost_net_ubuf_ref *ubufs; in handle_tx_zerocopy() local
910 ubuf->ctx = nvq->ubufs; in handle_tx_zerocopy()
918 ubufs = nvq->ubufs; in handle_tx_zerocopy()
919 atomic_inc(&ubufs->refcount); in handle_tx_zerocopy()
923 ubufs = NULL; in handle_tx_zerocopy()
937 vhost_net_ubuf_put(ubufs); in handle_tx_zerocopy()
1327 n->vqs[i].ubufs = NULL; in vhost_net_open()
1386 if (n->vqs[VHOST_NET_VQ_TX].ubufs) { in vhost_net_flush()
1391 vhost_net_ubuf_put_and_wait(n->vqs[VHOST_NET_VQ_TX].ubufs); in vhost_net_flush()
1394 atomic_set(&n->vqs[VHOST_NET_VQ_TX].ubufs->refcount, 1); in vhost_net_flush()
1508 struct vhost_net_ubuf_ref *ubufs, *oldubufs = NULL; in vhost_net_set_backend() local
1538 ubufs = vhost_net_ubuf_alloc(vq, in vhost_net_set_backend()
1540 if (IS_ERR(ubufs)) { in vhost_net_set_backend()
1541 r = PTR_ERR(ubufs); in vhost_net_set_backend()
1557 oldubufs = nvq->ubufs; in vhost_net_set_backend()
1558 nvq->ubufs = ubufs; in vhost_net_set_backend()
1585 if (ubufs) in vhost_net_set_backend()
1586 vhost_net_ubuf_put_wait_and_free(ubufs); in vhost_net_set_backend()