Lines Matching +full:virtio +full:- +full:device
1 /* SPDX-License-Identifier: GPL-2.0+ */
6 * VirtIO is a virtualization standard for network and disk device drivers
7 * where just the guest's device driver "knows" it is running in a virtual
10 * performance benefits of paravirtualization. In the U-Boot case, the guest
11 * is U-Boot itself, while the virtual environment are normally QEMU targets
12 * like ARM, RISC-V and x86.
14 * See http://docs.oasis-open.org/virtio/virtio/v1.0/virtio-v1.0.pdf for
15 * the VirtIO specification v1.0.
23 #define VIRTIO_ID_NET 1 /* virtio net */
24 #define VIRTIO_ID_BLOCK 2 /* virtio block */
27 #define VIRTIO_NET_DRV_NAME "virtio-net"
28 #define VIRTIO_BLK_DRV_NAME "virtio-blk"
32 /* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */
34 /* We have found a driver for the device */
40 /* Device entered invalid state, driver must reset it */
42 /* We've given up on this device */
46 * Virtio feature bits VIRTIO_TRANSPORT_F_START through VIRTIO_TRANSPORT_F_END
48 * the rest are per-device feature bits.
60 /* Can the device handle any descriptor layout? */
68 * If clear - device has the IOMMU bypass quirk feature.
69 * If set - use platform tools to detect the IOMMU.
76 /* Does the device support Single Root I/O Virtualization? */
80 * virtio scatter-gather struct
92 /* virtio bus operations */
95 * get_config() - read the value of a configuration field
97 * @vdev: the real virtio device
101 * @return 0 if OK, -ve on error
106 * set_config() - write the value of a configuration field
108 * @vdev: the real virtio device
112 * @return 0 if OK, -ve on error
117 * generation() - config generation counter
119 * @vdev: the real virtio device
121 * @return 0 if OK, -ve on error
125 * get_status() - read the status byte
127 * @vdev: the real virtio device
129 * @return 0 if OK, -ve on error
133 * set_status() - write the status byte
135 * @vdev: the real virtio device
137 * @return 0 if OK, -ve on error
141 * reset() - reset the device
143 * @vdev: the real virtio device
144 * @return 0 if OK, -ve on error
148 * get_features() - get the array of feature bits for this device
150 * @vdev: the real virtio device
152 * @return 0 if OK, -ve on error
156 * set_features() - confirm what device features we'll be using
158 * @vdev: the real virtio device
159 * @return 0 if OK, -ve on error
163 * find_vqs() - find virtqueues and instantiate them
165 * @vdev: the real virtio device
168 * @return 0 if OK, -ve on error
173 * del_vqs() - free virtqueues found by find_vqs()
175 * @vdev: the real virtio device
176 * @return 0 if OK, -ve on error
180 * notify() - notify the device to process the queue
182 * @vdev: the real virtio device
184 * @return 0 if OK, -ve on error
189 /* Get access to a virtio bus' operations */
190 #define virtio_get_ops(dev) ((struct dm_virtio_ops *)(dev)->driver->ops)
193 * virtio uclass per device private data
195 * @vqs: virtualqueue for the virtio device
196 * @vdev: the real virtio device underneath
197 * @legacy: is it a legacy device?
198 * @device: virtio device ID
199 * @vendor: virtio vendor ID
210 u32 device; member
220 * virtio_get_config() - read the value of a configuration field
222 * @vdev: the real virtio device
226 * @return 0 if OK, -ve on error
232 * virtio_set_config() - write the value of a configuration field
234 * @vdev: the real virtio device
238 * @return 0 if OK, -ve on error
244 * virtio_generation() - config generation counter
246 * @vdev: the real virtio device
248 * @return 0 if OK, -ve on error
253 * virtio_get_status() - read the status byte
255 * @vdev: the real virtio device
257 * @return 0 if OK, -ve on error
262 * virtio_set_status() - write the status byte
264 * @vdev: the real virtio device
266 * @return 0 if OK, -ve on error
271 * virtio_reset() - reset the device
273 * @vdev: the real virtio device
274 * @return 0 if OK, -ve on error
279 * virtio_get_features() - get the array of feature bits for this device
281 * @vdev: the real virtio device
283 * @return 0 if OK, -ve on error
288 * virtio_set_features() - confirm what device features we'll be using
290 * @vdev: the real virtio device
291 * @return 0 if OK, -ve on error
296 * virtio_find_vqs() - find virtqueues and instantiate them
298 * @vdev: the real virtio device
301 * @return 0 if OK, -ve on error
307 * virtio_del_vqs() - free virtqueues found by find_vqs()
309 * @vdev: the real virtio device
310 * @return 0 if OK, -ve on error
315 * virtio_notify() - notify the device to process the queue
317 * @vdev: the real virtio device
319 * @return 0 if OK, -ve on error
324 * virtio_add_status() - helper to set a new status code to the device
326 * @vdev: the real virtio device
332 * virtio_finalize_features() - helper to finalize features
334 * @vdev: the real virtio device
335 * @return 0 if OK, -ve on error
340 * virtio_driver_features_init() - initialize driver supported features
342 * This fills in the virtio device parent per child private data with the given
345 * This API should be called in the virtio device driver's bind method, so that
346 * later virtio transport uclass driver can utilize the driver supplied features
347 * to negotiate with the device on the final supported features.
349 * @priv: virtio uclass per device private data
362 * virtio_init() - helper to enumerate all known virtio devices
364 * @return 0 if OK, -ve on error
417 * __virtio_test_bit - helper to test feature bits
422 * @udev: the transport device
435 return uc_priv->features & BIT_ULL(fbit); in __virtio_test_bit()
439 * __virtio_set_bit - helper to set feature bits
443 * @udev: the transport device
456 uc_priv->features |= BIT_ULL(fbit); in __virtio_set_bit()
460 * __virtio_clear_bit - helper to clear feature bits
464 * @vdev: the transport device
477 uc_priv->features &= ~BIT_ULL(fbit); in __virtio_clear_bit()
481 * virtio_has_feature - helper to determine if this device has this feature
483 * Note this API is only usable after the virtio device driver's bind phase,
484 * as the feature has been negotiated between the device and the driver.
486 * @vdev: the virtio device
491 if (!(vdev->flags & DM_FLAG_BOUND)) in virtio_has_feature()
494 return __virtio_test_bit(vdev->parent, fbit); in virtio_has_feature()
508 struct virtio_dev_priv *uc_priv = dev_get_uclass_priv(vdev->parent); in virtio_is_little_endian()
510 return !uc_priv->legacy || virtio_legacy_is_little_endian(); in virtio_is_little_endian()
638 if (!typecheck(typeof((((structname *)0)->member)), *(ptr))) \
667 if (!typecheck(typeof((((structname *)0)->member)), *(ptr))) \
701 _r = -ENOENT; \