Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vhost: generialize backend features setting/getting

Move the backend features setting/getting from net.c to vhost.c to be
reused by vhost-vdpa.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20200804162048.22587-3-eli@mellanox.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Jason Wang and committed by
Michael S. Tsirkin
460f7ce1 b0bd82bf

+19 -16
+2 -16
drivers/vhost/net.c
··· 1615 1615 return err; 1616 1616 } 1617 1617 1618 - static int vhost_net_set_backend_features(struct vhost_net *n, u64 features) 1619 - { 1620 - int i; 1621 - 1622 - mutex_lock(&n->dev.mutex); 1623 - for (i = 0; i < VHOST_NET_VQ_MAX; ++i) { 1624 - mutex_lock(&n->vqs[i].vq.mutex); 1625 - n->vqs[i].vq.acked_backend_features = features; 1626 - mutex_unlock(&n->vqs[i].vq.mutex); 1627 - } 1628 - mutex_unlock(&n->dev.mutex); 1629 - 1630 - return 0; 1631 - } 1632 - 1633 1618 static int vhost_net_set_features(struct vhost_net *n, u64 features) 1634 1619 { 1635 1620 size_t vhost_hlen, sock_hlen, hdr_len; ··· 1715 1730 return -EFAULT; 1716 1731 if (features & ~VHOST_NET_BACKEND_FEATURES) 1717 1732 return -EOPNOTSUPP; 1718 - return vhost_net_set_backend_features(n, features); 1733 + vhost_set_backend_features(&n->dev, features); 1734 + return 0; 1719 1735 case VHOST_RESET_OWNER: 1720 1736 return vhost_net_reset_owner(n); 1721 1737 case VHOST_SET_OWNER:
+15
drivers/vhost/vhost.c
··· 2591 2591 } 2592 2592 EXPORT_SYMBOL_GPL(vhost_dequeue_msg); 2593 2593 2594 + void vhost_set_backend_features(struct vhost_dev *dev, u64 features) 2595 + { 2596 + struct vhost_virtqueue *vq; 2597 + int i; 2598 + 2599 + mutex_lock(&dev->mutex); 2600 + for (i = 0; i < dev->nvqs; ++i) { 2601 + vq = dev->vqs[i]; 2602 + mutex_lock(&vq->mutex); 2603 + vq->acked_backend_features = features; 2604 + mutex_unlock(&vq->mutex); 2605 + } 2606 + mutex_unlock(&dev->mutex); 2607 + } 2608 + EXPORT_SYMBOL_GPL(vhost_set_backend_features); 2594 2609 2595 2610 static int __init vhost_init(void) 2596 2611 {
+2
drivers/vhost/vhost.h
··· 214 214 struct vhost_msg_node *node); 215 215 struct vhost_msg_node *vhost_dequeue_msg(struct vhost_dev *dev, 216 216 struct list_head *head); 217 + void vhost_set_backend_features(struct vhost_dev *dev, u64 features); 218 + 217 219 __poll_t vhost_chr_poll(struct file *file, struct vhost_dev *dev, 218 220 poll_table *wait); 219 221 ssize_t vhost_chr_read_iter(struct vhost_dev *dev, struct iov_iter *to,