• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 use vmm_vhost::message::VhostUserProtocolFeatures;
6 
7 use crate::virtio::device_constants::gpu;
8 use crate::virtio::vhost::user::vmm::Connection;
9 use crate::virtio::vhost::user::vmm::QueueSizes;
10 use crate::virtio::vhost::user::vmm::Result;
11 use crate::virtio::vhost::user::vmm::VhostUserVirtioDevice;
12 use crate::virtio::DeviceType;
13 
14 impl VhostUserVirtioDevice {
new_gpu(base_features: u64, connection: Connection) -> Result<VhostUserVirtioDevice>15     pub fn new_gpu(base_features: u64, connection: Connection) -> Result<VhostUserVirtioDevice> {
16         let queue_sizes = QueueSizes::Fixed(gpu::QUEUE_SIZES.to_vec());
17         let max_queues = gpu::QUEUE_SIZES.len();
18 
19         let allow_features = 1 << gpu::VIRTIO_GPU_F_VIRGL
20             | 1 << gpu::VIRTIO_GPU_F_RESOURCE_UUID
21             | 1 << gpu::VIRTIO_GPU_F_RESOURCE_BLOB
22             | 1 << gpu::VIRTIO_GPU_F_CONTEXT_INIT
23             | 1 << gpu::VIRTIO_GPU_F_EDID
24             | 1 << gpu::VIRTIO_GPU_F_RESOURCE_SYNC
25             | 1 << gpu::VIRTIO_GPU_F_CREATE_GUEST_HANDLE;
26 
27         let allow_protocol_features = VhostUserProtocolFeatures::CONFIG
28             | VhostUserProtocolFeatures::SLAVE_REQ
29             | VhostUserProtocolFeatures::SHARED_MEMORY_REGIONS;
30 
31         VhostUserVirtioDevice::new(
32             connection,
33             DeviceType::Gpu,
34             queue_sizes,
35             max_queues,
36             allow_features,
37             allow_protocol_features,
38             base_features,
39             None,
40             true,
41         )
42     }
43 }
44