Skip to content

Commit

Permalink
virtio/vsock: add VIRTIO_VSOCK_F_DGRAM feature bit
Browse files Browse the repository at this point in the history
This commit adds a feature bit for virtio vsock to support datagrams.

Signed-off-by: Jiang Wang <jiang.wang@bytedance.com>
Signed-off-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
  • Loading branch information
beshleman authored and intel-lab-lkp committed Aug 15, 2022
1 parent 0c86cf7 commit db4515c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion drivers/vhost/vsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
enum {
VHOST_VSOCK_FEATURES = VHOST_FEATURES |
(1ULL << VIRTIO_F_ACCESS_PLATFORM) |
(1ULL << VIRTIO_VSOCK_F_SEQPACKET)
(1ULL << VIRTIO_VSOCK_F_SEQPACKET) |
(1ULL << VIRTIO_VSOCK_F_DGRAM)
};

enum {
Expand Down
1 change: 1 addition & 0 deletions include/uapi/linux/virtio_vsock.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

/* The feature bitmap for virtio vsock */
#define VIRTIO_VSOCK_F_SEQPACKET 1 /* SOCK_SEQPACKET supported */
#define VIRTIO_VSOCK_F_DGRAM 2 /* Host support dgram vsock */

struct virtio_vsock_config {
__le64 guest_cid;
Expand Down
8 changes: 6 additions & 2 deletions net/vmw_vsock/virtio_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static struct virtio_transport virtio_transport; /* forward declaration */
struct virtio_vsock {
struct virtio_device *vdev;
struct virtqueue *vqs[VSOCK_VQ_MAX];
bool has_dgram;

/* Virtqueue processing is deferred to a workqueue */
struct work_struct tx_work;
Expand Down Expand Up @@ -709,7 +710,6 @@ static int virtio_vsock_probe(struct virtio_device *vdev)
}

vsock->vdev = vdev;

vsock->rx_buf_nr = 0;
vsock->rx_buf_max_nr = 0;
atomic_set(&vsock->queued_replies, 0);
Expand All @@ -726,6 +726,9 @@ static int virtio_vsock_probe(struct virtio_device *vdev)
if (virtio_has_feature(vdev, VIRTIO_VSOCK_F_SEQPACKET))
vsock->seqpacket_allow = true;

if (virtio_has_feature(vdev, VIRTIO_VSOCK_F_DGRAM))
vsock->has_dgram = true;

vdev->priv = vsock;

ret = virtio_vsock_vqs_init(vsock);
Expand Down Expand Up @@ -820,7 +823,8 @@ static struct virtio_device_id id_table[] = {
};

static unsigned int features[] = {
VIRTIO_VSOCK_F_SEQPACKET
VIRTIO_VSOCK_F_SEQPACKET,
VIRTIO_VSOCK_F_DGRAM
};

static struct virtio_driver virtio_vsock_driver = {
Expand Down

0 comments on commit db4515c

Please sign in to comment.