Lines Matching refs:ubufs
125 struct vhost_net_ubuf_ref *ubufs; member
237 struct vhost_net_ubuf_ref *ubufs; in vhost_net_ubuf_alloc() local
241 ubufs = kmalloc(sizeof(*ubufs), GFP_KERNEL); in vhost_net_ubuf_alloc()
242 if (!ubufs) in vhost_net_ubuf_alloc()
244 atomic_set(&ubufs->refcount, 1); in vhost_net_ubuf_alloc()
245 init_waitqueue_head(&ubufs->wait); in vhost_net_ubuf_alloc()
246 ubufs->vq = vq; in vhost_net_ubuf_alloc()
247 return ubufs; in vhost_net_ubuf_alloc()
250 static int vhost_net_ubuf_put(struct vhost_net_ubuf_ref *ubufs) in vhost_net_ubuf_put() argument
252 int r = atomic_sub_return(1, &ubufs->refcount); in vhost_net_ubuf_put()
254 wake_up(&ubufs->wait); in vhost_net_ubuf_put()
258 static void vhost_net_ubuf_put_and_wait(struct vhost_net_ubuf_ref *ubufs) in vhost_net_ubuf_put_and_wait() argument
260 vhost_net_ubuf_put(ubufs); in vhost_net_ubuf_put_and_wait()
261 wait_event(ubufs->wait, !atomic_read(&ubufs->refcount)); in vhost_net_ubuf_put_and_wait()
264 static void vhost_net_ubuf_put_wait_and_free(struct vhost_net_ubuf_ref *ubufs) in vhost_net_ubuf_put_wait_and_free() argument
266 vhost_net_ubuf_put_and_wait(ubufs); in vhost_net_ubuf_put_wait_and_free()
267 kfree(ubufs); in vhost_net_ubuf_put_wait_and_free()
312 n->vqs[i].ubufs = NULL; in vhost_net_vq_reset()
389 struct vhost_net_ubuf_ref *ubufs = ubuf->ctx; in vhost_zerocopy_callback() local
390 struct vhost_virtqueue *vq = ubufs->vq; in vhost_zerocopy_callback()
398 cnt = vhost_net_ubuf_put(ubufs); in vhost_zerocopy_callback()
875 struct vhost_net_ubuf_ref *ubufs; in handle_tx_zerocopy() local
912 ubuf->ctx = nvq->ubufs; in handle_tx_zerocopy()
921 ubufs = nvq->ubufs; in handle_tx_zerocopy()
922 atomic_inc(&ubufs->refcount); in handle_tx_zerocopy()
926 ubufs = NULL; in handle_tx_zerocopy()
942 vhost_net_ubuf_put(ubufs); in handle_tx_zerocopy()
1335 n->vqs[i].ubufs = NULL; in vhost_net_open()
1389 if (n->vqs[VHOST_NET_VQ_TX].ubufs) { in vhost_net_flush()
1394 vhost_net_ubuf_put_and_wait(n->vqs[VHOST_NET_VQ_TX].ubufs); in vhost_net_flush()
1397 atomic_set(&n->vqs[VHOST_NET_VQ_TX].ubufs->refcount, 1); in vhost_net_flush()
1506 struct vhost_net_ubuf_ref *ubufs, *oldubufs = NULL; in vhost_net_set_backend() local
1539 ubufs = vhost_net_ubuf_alloc(vq, in vhost_net_set_backend()
1541 if (IS_ERR(ubufs)) { in vhost_net_set_backend()
1542 r = PTR_ERR(ubufs); in vhost_net_set_backend()
1562 oldubufs = nvq->ubufs; in vhost_net_set_backend()
1563 nvq->ubufs = ubufs; in vhost_net_set_backend()
1590 if (ubufs) in vhost_net_set_backend()
1591 vhost_net_ubuf_put_wait_and_free(ubufs); in vhost_net_set_backend()