Commit b98ac591 authored by Jean-Philippe Brucker's avatar Jean-Philippe Brucker Committed by Will Deacon
Browse files

virtio: Add get_vq_count() callback



Modern virtio requires devices to report how many queues they support. Add
an operation to query all devices about their capacities.
Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: default avatarJulien Thierry <julien.thierry@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent 95242e44
...@@ -184,6 +184,7 @@ struct virtio_ops { ...@@ -184,6 +184,7 @@ struct virtio_ops {
u8 *(*get_config)(struct kvm *kvm, void *dev); u8 *(*get_config)(struct kvm *kvm, void *dev);
u32 (*get_host_features)(struct kvm *kvm, void *dev); u32 (*get_host_features)(struct kvm *kvm, void *dev);
void (*set_guest_features)(struct kvm *kvm, void *dev, u32 features); void (*set_guest_features)(struct kvm *kvm, void *dev, u32 features);
int (*get_vq_count)(struct kvm *kvm, void *dev);
int (*init_vq)(struct kvm *kvm, void *dev, u32 vq, u32 page_size, int (*init_vq)(struct kvm *kvm, void *dev, u32 vq, u32 page_size,
u32 align, u32 pfn); u32 align, u32 pfn);
int (*notify_vq)(struct kvm *kvm, void *dev, u32 vq); int (*notify_vq)(struct kvm *kvm, void *dev, u32 vq);
......
...@@ -1440,6 +1440,11 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) ...@@ -1440,6 +1440,11 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)
return size; return size;
} }
static int get_vq_count(struct kvm *kvm, void *dev)
{
return NUM_VIRT_QUEUES;
}
struct virtio_ops p9_dev_virtio_ops = { struct virtio_ops p9_dev_virtio_ops = {
.get_config = get_config, .get_config = get_config,
.get_host_features = get_host_features, .get_host_features = get_host_features,
...@@ -1450,6 +1455,7 @@ struct virtio_ops p9_dev_virtio_ops = { ...@@ -1450,6 +1455,7 @@ struct virtio_ops p9_dev_virtio_ops = {
.get_pfn_vq = get_pfn_vq, .get_pfn_vq = get_pfn_vq,
.get_size_vq = get_size_vq, .get_size_vq = get_size_vq,
.set_size_vq = set_size_vq, .set_size_vq = set_size_vq,
.get_vq_count = get_vq_count,
}; };
int virtio_9p_rootdir_parser(const struct option *opt, const char *arg, int unset) int virtio_9p_rootdir_parser(const struct option *opt, const char *arg, int unset)
......
...@@ -243,6 +243,11 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) ...@@ -243,6 +243,11 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)
return size; return size;
} }
static int get_vq_count(struct kvm *kvm, void *dev)
{
return NUM_VIRT_QUEUES;
}
struct virtio_ops bln_dev_virtio_ops = { struct virtio_ops bln_dev_virtio_ops = {
.get_config = get_config, .get_config = get_config,
.get_host_features = get_host_features, .get_host_features = get_host_features,
...@@ -253,6 +258,7 @@ struct virtio_ops bln_dev_virtio_ops = { ...@@ -253,6 +258,7 @@ struct virtio_ops bln_dev_virtio_ops = {
.get_pfn_vq = get_pfn_vq, .get_pfn_vq = get_pfn_vq,
.get_size_vq = get_size_vq, .get_size_vq = get_size_vq,
.set_size_vq = set_size_vq, .set_size_vq = set_size_vq,
.get_vq_count = get_vq_count,
}; };
int virtio_bln__init(struct kvm *kvm) int virtio_bln__init(struct kvm *kvm)
......
...@@ -248,10 +248,16 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) ...@@ -248,10 +248,16 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)
return size; return size;
} }
static int get_vq_count(struct kvm *kvm, void *dev)
{
return NUM_VIRT_QUEUES;
}
static struct virtio_ops blk_dev_virtio_ops = { static struct virtio_ops blk_dev_virtio_ops = {
.get_config = get_config, .get_config = get_config,
.get_host_features = get_host_features, .get_host_features = get_host_features,
.set_guest_features = set_guest_features, .set_guest_features = set_guest_features,
.get_vq_count = get_vq_count,
.init_vq = init_vq, .init_vq = init_vq,
.notify_status = notify_status, .notify_status = notify_status,
.notify_vq = notify_vq, .notify_vq = notify_vq,
......
...@@ -202,10 +202,16 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) ...@@ -202,10 +202,16 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)
return size; return size;
} }
static int get_vq_count(struct kvm *kvm, void *dev)
{
return VIRTIO_CONSOLE_NUM_QUEUES;
}
static struct virtio_ops con_dev_virtio_ops = { static struct virtio_ops con_dev_virtio_ops = {
.get_config = get_config, .get_config = get_config,
.get_host_features = get_host_features, .get_host_features = get_host_features,
.set_guest_features = set_guest_features, .set_guest_features = set_guest_features,
.get_vq_count = get_vq_count,
.init_vq = init_vq, .init_vq = init_vq,
.notify_status = notify_status, .notify_status = notify_status,
.notify_vq = notify_vq, .notify_vq = notify_vq,
......
...@@ -681,10 +681,18 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) ...@@ -681,10 +681,18 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)
return size; return size;
} }
static int get_vq_count(struct kvm *kvm, void *dev)
{
struct net_dev *ndev = dev;
return ndev->queue_pairs * 2 + 1;
}
static struct virtio_ops net_dev_virtio_ops = { static struct virtio_ops net_dev_virtio_ops = {
.get_config = get_config, .get_config = get_config,
.get_host_features = get_host_features, .get_host_features = get_host_features,
.set_guest_features = set_guest_features, .set_guest_features = set_guest_features,
.get_vq_count = get_vq_count,
.init_vq = init_vq, .init_vq = init_vq,
.get_pfn_vq = get_pfn_vq, .get_pfn_vq = get_pfn_vq,
.get_size_vq = get_size_vq, .get_size_vq = get_size_vq,
......
...@@ -141,6 +141,11 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) ...@@ -141,6 +141,11 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)
return size; return size;
} }
static int get_vq_count(struct kvm *kvm, void *dev)
{
return NUM_VIRT_QUEUES;
}
static struct virtio_ops rng_dev_virtio_ops = { static struct virtio_ops rng_dev_virtio_ops = {
.get_config = get_config, .get_config = get_config,
.get_host_features = get_host_features, .get_host_features = get_host_features,
...@@ -150,6 +155,7 @@ static struct virtio_ops rng_dev_virtio_ops = { ...@@ -150,6 +155,7 @@ static struct virtio_ops rng_dev_virtio_ops = {
.get_pfn_vq = get_pfn_vq, .get_pfn_vq = get_pfn_vq,
.get_size_vq = get_size_vq, .get_size_vq = get_size_vq,
.set_size_vq = set_size_vq, .set_size_vq = set_size_vq,
.get_vq_count = get_vq_count,
}; };
int virtio_rng__init(struct kvm *kvm) int virtio_rng__init(struct kvm *kvm)
......
...@@ -167,6 +167,11 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) ...@@ -167,6 +167,11 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)
return size; return size;
} }
static int get_vq_count(struct kvm *kvm, void *dev)
{
return NUM_VIRT_QUEUES;
}
static struct virtio_ops scsi_dev_virtio_ops = { static struct virtio_ops scsi_dev_virtio_ops = {
.get_config = get_config, .get_config = get_config,
.get_host_features = get_host_features, .get_host_features = get_host_features,
...@@ -179,6 +184,7 @@ static struct virtio_ops scsi_dev_virtio_ops = { ...@@ -179,6 +184,7 @@ static struct virtio_ops scsi_dev_virtio_ops = {
.notify_vq = notify_vq, .notify_vq = notify_vq,
.notify_vq_gsi = notify_vq_gsi, .notify_vq_gsi = notify_vq_gsi,
.notify_vq_eventfd = notify_vq_eventfd, .notify_vq_eventfd = notify_vq_eventfd,
.get_vq_count = get_vq_count,
}; };
static void virtio_scsi_vhost_init(struct kvm *kvm, struct scsi_dev *sdev) static void virtio_scsi_vhost_init(struct kvm *kvm, struct scsi_dev *sdev)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment