XenevaOS
Loading...
Searching...
No Matches
virtio.h
Go to the documentation of this file.
1#ifndef __LINUX_VIRTIO_H__
2#define __LINUX_VIRTIO_H__
3
4#include <stdint.h>
5#include <stddef.h>
6#include <linux/kernel.h>
7/*
8 * struct scatterlist used to be declared here, five lines below, and now
9 * lives in <linux/scatterlist.h> -- mainline's home for it, so a ported
10 * source includes the header mainline tells it to. Including it means every
11 * file that reaches virtio.h still sees the type (nothing here has to
12 * change), and there is still exactly one definition of it.
13 */
14#include <linux/scatterlist.h>
15/*
16 * memcpy, for virtio_cread() below: a config-space read is a copy of the
17 * caller's own width out of device memory, and this header's macro is where
18 * that copy is spelled. Included here rather than left to the expansion site
19 * so a caller need not have remembered it -- a macro expands in its own
20 * context, and `virtio_cread()` reaching an undeclared memcpy() would be an
21 * error attributed to the driver that never named memcpy.
22 */
23#include <linux/string.h>
24/*
25 * The next three are what mainline's <linux/virtio.h> pulls in through
26 * <linux/device.h>, which DCL does not have:
27 *
28 * mainline virtio.h -> device.h -> kobject.h -> sysfs.h -> kernfs.h
29 * \-> pm.h \-> completion.h \-> idr.h
30 *
31 * The chain was walked against the header package rather than assumed, and
32 * it is why a ported driver can write `struct completion have_data`,
33 * `pm_sleep_ptr(...)`, `DEFINE_IDA(...)` and `ida_alloc(...)` while including
34 * only <linux/virtio.h> the way it does upstream. Flattening five headers
35 * into three is the whole content of DCL's missing device layer.
36 */
37#include <linux/completion.h>
38#include <linux/pm.h>
39#include <linux/idr.h>
40/*
41 * module.h is needed for module_virtio_driver(), defined at the bottom of
42 * this file: the macro expands to a module_init() call, and module.h is what
43 * owns module_init() (it maps it to DCL_INITCALL via <linux/init.h>). No
44 * cycle -- module.h reaches init.h and export.h, neither of which comes back
45 * here, and kernel.h already includes module.h before it reaches this file.
46 */
47#include <linux/module.h>
48#include <linux/fs.h> /* struct device -- virtio_device carries one (mainline
49 * does too, as `struct device dev;`), and fs.h is where
50 * DCL's is defined. fs.h includes only <stdint.h> and
51 * <stddef.h>, so this cannot cycle. */
52#include <linux/device/driver.h> /* struct device_driver -- shared with
53 * pci.h since the scanout stage; see the
54 * note where the struct used to live,
55 * below virtio_device. */
56#include <linux/list.h> /* struct list_head -- virtio_device.vqs, virtqueue.list */
57#include <Drivers/virtio.h>
58
59/* ─── Feature bits ─── */
60#define VIRTIO_F_NOTIFY_ON_EMPTY 24
61#define VIRTIO_RING_F_INDIRECT_DESC 28
62#define VIRTIO_RING_F_EVENT_IDX 29
63
64/*
65 * VIRTIO_DEV_ANY_ID -- the id_table wildcard.
66 *
67 * mainline: `#define VIRTIO_DEV_ANY_ID ((unsigned int)-1)`. It has to come
68 * out as 0xFFFFFFFF, not 0 and not -1 signed, because DCL/virtio_shim.c
69 * matches on it directly:
70 *
71 * if (id->device == virtio_dev && id->vendor == 0xFFFFFFFF)
72 *
73 * (unsigned)-1 is the only spelling that satisfies both the comparison and
74 * the struct field, which is __u32. A driver that matched on 0 instead would
75 * only ever bind to a device reporting vendor 0, which none do -- so the
76 * failure would be "probe never called", with nothing to say why.
77 */
78#define VIRTIO_DEV_ANY_ID ((unsigned int)-1)
79
80/*
81 * ─── Device status ───
82 *
83 * Not defined here: <uapi/linux/virtio_config.h> is the single source for
84 * the VIRTIO_CONFIG_S_* byte, and DCL's <linux/virtio_config.h> already
85 * pulls it in. This header used to carry its own copy of five of them, and
86 * the two copies were spelled differently -- `128` here against `0x80`
87 * there -- which is a -Wmacro-redefined warning the moment a TU includes
88 * both (virtio_console.c does, via virtio_console.h). Identical values do
89 * not warn and differing ones do, so "make them match" was a fix that
90 * stopped working the first time someone edited either side; taking the
91 * duplicate out is the fix that cannot stop working.
92 *
93 * Everything else this header defines -- VRING_DESC_F_*, VIRTIO_RING_F_*,
94 * VIRTIO_DEV_ANY_ID -- is not in the uapi header at all.
95 */
97
98/* ─── Descriptor flags ─── */
99#define VRING_DESC_F_NEXT 1
100#define VRING_DESC_F_WRITE 2
101#define VRING_DESC_F_INDIRECT 4
102
103/* ─── Forward declarations ─── */
104struct virtio_device;
105struct virtio_driver;
106struct virtqueue;
107
109 const char* name;
110 void (*callback)(struct virtqueue* vq);
111 bool ctx;
112};
113
114/* The .ko indexes these by fixed offset */
116 void (*get)(struct virtio_device* vdev, unsigned offset, void* buf, unsigned len);
117 void (*set)(struct virtio_device* vdev, unsigned offset, const void* buf, unsigned len);
118 u32 (*generation)(struct virtio_device* vdev);
119 u8 (*get_status)(struct virtio_device* vdev);
120 void (*set_status)(struct virtio_device* vdev, u8 status);
121 void (*reset)(struct virtio_device* vdev);
122 int (*find_vqs)(struct virtio_device* vdev,
123 unsigned nvqs,
124 struct virtqueue** vqs,
125 struct virtqueue_info* vqs_info,
126 void* desc);
127 void (*del_vqs)(struct virtio_device* vdev);
128 void (*synchronize_cbs)(struct virtio_device* vdev);
130 void (*get_extended_features)(struct virtio_device* vdev, u64* features);
131 int (*finalize_features)(struct virtio_device* vdev);
132 const char* (*bus_name)(struct virtio_device* vdev);
133 int (*set_vq_affinity)(struct virtqueue* vq, const void* cpu_mask);
134 const void* (*get_vq_affinity)(struct virtio_device* vdev, int index);
135 bool (*get_shm_region)(struct virtio_device* vdev, void* region, u8 id);
136 int (*disable_vq_and_reset)(struct virtqueue* vq);
138
140};
141
142/*
143 * struct virtio_device_id -- defined *before* struct virtio_device below,
144 * which carries one by value. It used to sit underneath; moving it up is the
145 * only way a value member can be spelled, and nothing that references the type
146 * by name cared where it was.
147 *
148 * mainline's is the same two __u32 words. The driver reads `vdev->id.device`
149 * (virtio_console.c:332) to tell an rproc serial device from a virtio-console
150 * one.
151 */
156
158 int index;
159 void* drv_data;
160 unsigned char _linux_prefix[0x328];
162 unsigned char _mid[0x30];
163 void* priv;
165
166 /*
167 * Appended, and appended is the point: everything above is the layout
168 * the prebuilt modules were assembled against, `_linux_prefix` included,
169 * so no existing offset moves and the static asserts elsewhere still
170 * describe the same bytes. mainline carries `id` and `dev` inside the
171 * region DCL covers with `_linux_prefix`, but a blob cannot answer a
172 * *member* reference -- `vdev->dev.parent` (virtio_console.c:433) and
173 * `vdev->id.device` (:332) are field accesses the preprocessor never
174 * sees -- so the three members below exist for them, and they are the
175 * only three a ported source names today.
176 *
177 * id mainline's device identity. Zeroed by virtio_device_register()
178 * and set to the device type there; safe to read as zero even
179 * when it is not, because the only reader
180 * (is_rproc_serial(), :332) sits behind `is_rproc_enabled &&
181 * ...` and is_rproc_enabled is IS_ENABLED(CONFIG_REMOTEPROC)
182 * with CONFIG_REMOTEPROC 0 -- a constant fold, so the load
183 * never happens at runtime.
184 *
185 * dev mainline's embedded device. Never registered with anything
186 * (DCL has no device model to register it with); its
187 * `parent` is set by virtio_device_register() to the PCI
188 * fabric's device for the function behind it -- the relation
189 * virtio-gpu's probe reads (drm_dev_alloc()'s parent
190 * argument, then its dev_is_pci() quirk gate). The DMA path
191 * at virtio_console.c:433 reads `parent` only under
192 * is_rproc_serial(), whose first term is constant-false on
193 * this port: it never runs, and no NULL here could change
194 * that.
195 *
196 * vqs the head of this device's virtqueue list, so mainline's
197 * `virtio_device_for_each_vq()` (used once, in remove_vqs())
198 * can walk real queues instead of a list that does not exist.
199 * Initialised by virtio_device_register() and populated by
200 * shim_find_vqs(). See the note on virtqueue.list for why the
201 * snapshot copy in _virtio_devices[] needs its own head.
202 */
204 struct device dev;
206};
207
208/*
209 * struct device_driver now lives at upstream's path, <linux/device/driver.h>
210 * (included above), because pci_driver writes `.driver.pm` too and two
211 * definitions of the tag would collide in any translation unit that includes
212 * both buses -- the vendored virtio-gpu driver includes <linux/pci.h>
213 * alongside this header. Everything this comment used to promise moved with
214 * the struct: `name` at offset 0, 152 bytes exactly, `_rest` covering
215 * mainline's unmodelled bind machinery, and virtio_driver's field offsets
216 * (id_table at 152, probe at 200) untouched. One thing changed while moving:
217 * the 144-byte tail is 136 now, and the eight bytes that went missing are
218 * `pm` -- the one field bochs.c's pci_driver initialises through the same
219 * tag. Nothing read the padding, so no existing caller sees a difference.
220 */
221
223 /*
224 * mainline's first member is `struct device_driver driver;`, so this
225 * is the same shape. See the note above for why it is nested now.
226 */
229 /*
230 * mainline's five members between id_table and probe, spelled out
231 * instead of `unsigned char _gap[40]`.
232 *
233 * The gap was never arbitrary: mainline's layout there is
234 *
235 * const unsigned int *feature_table; 8 160
236 * unsigned int feature_table_size; 4 168
237 * const unsigned int *feature_table_legacy; 8 176
238 * unsigned int feature_table_size_legacy; 4 184
239 * int (*validate)(struct virtio_device *); 8 192
240 *
241 * which is 8 + 4 + pad4 + 8 + 4 + pad4 + 8 = 40 bytes, and probe lands
242 * at 200 -- exactly where the gap put it. So this replaces padding with
243 * the fields the padding was standing in for and moves nothing: the
244 * offsets after it are identical, which is the condition the note above
245 * says has to hold.
246 *
247 * virtio_console.c:2171/:2185 initialise feature_table and
248 * feature_table_size by name ("field designator '_gap' does not refer to
249 * any field" is the error a designator cannot make against padding), and
250 * feature_table_legacy/validate are here for the same reason -- leaving
251 * two of the five as padding would mean the next mainline driver that
252 * names them hit a wall DCL had already decided how to take down.
253 *
254 * Nothing in DCL *reads* feature_table: register_virtio_driver() only
255 * ever touches ->probe, ->scan and ->id_table, and feature negotiation
256 * does not happen here (see __virtio_test_bit() in <linux/virtio_config.h>).
257 * The members exist so the initialiser compiles and the layout matches.
258 */
259 const unsigned int* feature_table;
260 unsigned int feature_table_size;
261 const unsigned int* feature_table_legacy;
263 int (*validate)(struct virtio_device* vdev);
264 int (*probe)(struct virtio_device* vdev);
265 void (*scan)(struct virtio_device* vdev);
266 void (*remove)(struct virtio_device* vdev);
267 void (*config_changed)(struct virtio_device* vdev);
268 /*
269 * DCL delta: mainline's .shutdown slot, added with the virtio-gpu port
270 * -- virtgpu_drv.c:178 initialises it by designator. Appended here,
271 * after the pinned prefix the note above describes, so the offsets the
272 * prebuilt module indexes do not move; no DCL path drives a device
273 * shutdown, so nothing reads it.
274 */
275 void (*shutdown)(struct virtio_device* vdev);
276 int (*freeze)(struct virtio_device* vdev);
277 int (*restore)(struct virtio_device* vdev);
278};
279
280struct virtqueue {
281 unsigned char _linux_prefix[32];
290 const char* name;
291 void (*callback)(struct virtqueue* vq);
292 void* cookies[256];
294 /*
295 * Whether the device behind this queue has gone away -- mainline's
296 * own member, and the whole of virtqueue_is_broken()'s answer. It is
297 * set by virtio_break_device(), which is what virtcons_remove() calls
298 * first (virtio_console.c:1920) so the flush loops below it stop
299 * waiting on a device that has already left; before that call it is
300 * false, and the `while (!virtqueue_get_buf() && !is_broken()) cpu_relax()`
301 * spins exit on the first condition as they are meant to.
302 */
303 bool broken;
304 /*
305 * This queue's node in its device's virtqueue list -- what
306 * virtio_device_for_each_vq() walks in virtio_console.c's remove_vqs().
307 * Appended last for the reason every append in this header is: the
308 * `_linux_prefix` up front is the region a prebuilt module indexes by
309 * fixed offset, and nothing before it may move.
310 *
311 * kmalloc(sizeof(*vq)) in shim_find_vqs() sizes the object from this
312 * very struct, so the extra 16 bytes are allocated with the rest and
313 * there is no fixed-size container anywhere to overrun. list_add() sets
314 * both links, so the memset() beside it need not.
315 */
317};
318
319/*
320 * is_virtio_device(dev) -- mainline asks `dev->bus == &virtio_bus` (v7.2
321 * virtio.h). DCL names no bus object to compare against -- struct device
322 * is fs.h's pinned ABI layout, and the bus field mainline reads is not a
323 * member the pin preserves -- and there is one device family in the tree:
324 * every struct device* a vendored driver holds here came out of this
325 * stack. Added with the virtio-gpu port, whose vram path guards its UUID
326 * work with it; any non-NULL device is one of ours.
327 */
328static inline bool is_virtio_device(struct device* dev)
329{
330 return dev != NULL;
331}
332
335
336/*
337 * module_virtio_driver(drv) -- register a static struct virtio_driver at
338 * boot. This is how virtio-rng.c ends: `module_virtio_driver(virtio_rng_driver);`
339 *
340 * mainline expands it through module_driver() into an init function *and* a
341 * matching exit function. DCL has the init half only, and the reason the exit
342 * half is dropped rather than stubbed is mechanical: <linux/module.h>'s
343 * module_exit() is an empty macro here (DCL has no unload path), so a
344 * `static void __exit drv##_exit(void)` would be a function nothing ever
345 * references -- -Wunused-function on every build of every driver that uses
346 * this macro. An unload path that cannot run is worse than no unload path.
347 *
348 * The init half is real, though, and it is worth being precise about *how*:
349 * module.h maps module_init() to DCL_INITCALL(), which stores the function in
350 * the named global __dcl_initcall_<fn>. Nothing discovers or schedules it --
351 * DclRunInitcalls() (DCL/linux_mm_shim.c) calls that global by name. So
352 * bringing up a driver through this macro has two halves: it compiles here,
353 * and its line goes into DclRunInitcalls() there. The second half is not
354 * automatic, and forgetting it produces exactly the symptom a prebuilt .ko
355 * used to produce: everything builds, and probe is never called.
356 *
357 * Returns register_virtio_driver()'s int, which is what DclRunInitcalls()
358 * expects from an initcall.
359 */
360#define module_virtio_driver(drv) \
361 static int __init drv##_init(void) \
362 { \
363 return register_virtio_driver(&(drv)); \
364 } \
365 module_init(drv##_init)
366
369
370/*
371 * virtio_find_single_vq / virtio_device_ready / virtio_reset_device.
372 *
373 * mainline defines the first two as static inline here and the third in
374 * <linux/virtio.h> too; DCL declares them and puts the bodies in
375 * DCL/virtio_shim.c and DCL/linux_kmod_shim.c instead.
376 *
377 * The reason is include order, not taste: all three are one line each, but
378 * find_single_vq has to report a failed find_vqs as an error pointer, and
379 * <linux/err.h> reaches back into <linux/kernel.h> -- which includes *this*
380 * file. A definition here would be expanded against a half-processed
381 * kernel.h whenever something includes kernel.h first, and kernel.h always
382 * comes first. In a .c the same header is fully read, and a driver cannot
383 * tell the difference: virtio-rng.c writes `if (IS_ERR(vi->vq))` and gets
384 * an extern with the same signature either way.
385 *
386 * virtio_reset_device's body already existed (linux_kmod_shim.c:19) with no
387 * declaration anywhere -- it worked only because the prebuilt .ko carried its
388 * own inline copy of it.
389 */
391 void (*cb)(struct virtqueue* vq),
392 const char* name);
395
398
399/*
400 * virtio_cread(vdev, type, field, ptr) -- copy `sizeof(*ptr)` bytes of config
401 * space, starting at offsetof(type, field), into *ptr.
402 *
403 * The previous version of this macro cast the offset address to `type *` and
404 * dereferenced it:
405 *
406 * *(ptr) = *((type *)(base + offsetof(type, field)));
407 *
408 * which yields a `type` -- the whole struct the field belongs to -- and
409 * assigns it to *ptr. virtio_console.c:1794/:1795 are exactly that shape
410 * gone wrong: `virtio_cread(vdev, struct virtio_console_config, cols, &cols)`
411 * with cols a u16, so the assignment was u16 = struct virtio_console_config
412 * and clang said so three times. Taking the caller's width instead of the
413 * container's is what mainline's `sizeof(virtio_cread_v)` does
414 * (linux/virtio_config.h:466), so this is the same read with mainline's
415 * arithmetic and DCL's copy -- the difference being that DCL has no
416 * might_sleep() to make, because nothing here can block.
417 *
418 * The `char *` cast matters: device_config_base is `void *`, and while clang
419 * permits void-pointer arithmetic as an extension it does so one element at a
420 * time, which for a one-byte element happens to be correct -- by accident.
421 */
422#define virtio_cread(vdev, type, field, ptr) \
423 do { \
424 memcpy((ptr), \
425 (char*)(vdev)->config->device_config_base + \
426 offsetof(type, field), \
427 sizeof(*(ptr))); \
428 } while (0)
429
430/*
431 * virtio_cread_bytes() -- mainline's arbitrary-length config read. The
432 * virtio-input driver uses it for the device name/serial and for the raw
433 * capability bitmaps, which are byte streams rather than fields of a known
434 * type. DCL's config window is the device BAR already mapped by
435 * virtio_shim.c, so the read is the same copy virtio_cread() makes.
436 */
437static inline void virtio_cread_bytes(struct virtio_device* vdev,
438 unsigned int offset, void* buf,
439 size_t len)
440{
441 memcpy(buf, (char*)vdev->config->device_config_base + offset, len);
442}
443
444/*
445 * struct scatterlist moved to <linux/scatterlist.h>; see the note there for
446 * why DCL's is { buf, len } rather than mainline's page_link/offset/length.
447 */
448
450 unsigned nvqs,
451 struct virtqueue** vqs,
452 struct virtqueue_info* vqs_info,
453 void* desc);
455
456/*
457 * mainline's fifth argument is gfp_t, and both callers pass one
458 * (virtio-rng.c:65 GFP_KERNEL, virtio_console.c:490 GFP_ATOMIC). It is
459 * accepted and dropped for the reason slab.h drops its own flags: Xeneva's
460 * allocator has no GFP_KERNEL against GFP_ATOMIC to distinguish. The `sg` +
461 * `num` pair bounds the walk DCL's way: mainline wraps this chain head into
462 * a one-element sgs[] and the chain's own end bounds the walk, while DCL's
463 * scatterlist has no end marker (see <linux/scatterlist.h>), so `num` is
464 * the bound -- the same entries either way for the single-entry chains
465 * every caller passes.
466 */
468 struct virtqueue* vq, struct scatterlist* sg, unsigned int num_in, void* data, gfp_t gfp);
469
470/*
471 * The cache-clean spelling mainline added for DMA-coherent architectures.
472 * DCL has no per-buffer cache metadata to hand the ring code, so the body
473 * is the plain add; correctness for device-written buffers is handled by
474 * the invalidate in virtqueue_get_buf().
475 */
477 struct virtqueue* vq, struct scatterlist* sg, unsigned int num_in, void* data, gfp_t gfp);
478
479unsigned int virtqueue_get_vring_size(const struct virtqueue* vq);
480
481/*
482 * virtqueue_add_sgs() -- mainline's multi-chain submit: `sgs[]` is an array
483 * of scatterlist heads, the first `out_cnt` readable by the device and the
484 * next `in_cnt` writable. The vendored virtio-gpu command path passes the
485 * array whole (virtgpu_vq.c builds `struct scatterlist *sgs[3]` at :361,
486 * :415 and :566), and an earlier spelling of this argument as one flat
487 * `struct scatterlist sg[]` is what made the shape wrong: the walk in
488 * virtio_shim.c read the pointer array as though it were buffers, QEMU
489 * rejected the control queue's first command with "zero sized buffers are
490 * not allowed", and the device went silent before the display-info wait at
491 * the end of virtio_gpu_init() could be answered.
492 *
493 * DCL's scatterlist has no chain terminator, so a chain is exactly one
494 * entry here: every producer in this tree builds single-entry chains (the
495 * vcmd/vresp/vout slots at virtgpu_vq.c:437-495, the cursor submit's
496 * :560-566), and the one longer-chain producer, the vmalloc_to_sgt()
497 * branch at :474, sits behind is_vmalloc_addr(), constant false here --
498 * arming that branch means teaching the walk to continue through the chain
499 * it produces, and nothing else reads differently.
500 *
501 * The last argument is mainline's gfp_t; the old `void *ctx` slot took the
502 * callers' GFP_ATOMIC as an integer-into-pointer constraint violation, and
503 * nothing reads the value either way, same trade as add_inbuf() above.
504 */
506 struct scatterlist* sgs[],
507 unsigned int out_cnt,
508 unsigned int in_cnt,
509 void* data,
510 gfp_t gfp);
511
512bool virtqueue_kick(struct virtqueue* vq);
515void* virtqueue_get_buf(struct virtqueue* vq, unsigned int* len);
516
517/*
518 * The five virtqueue/virtio entry points virtio_console.c calls that had no
519 * declaration anywhere in DCL. Bodies are in DCL/virtio_shim.c beside the
520 * ones above; the signatures are mainline's, character for character, because
521 * a mismatch here is invisible to the linker (C does not mangle) and would
522 * show up as a call that links and reads the wrong register.
523 *
524 * add_outbuf the transmit half of add_inbuf -- a *device*-bound
525 * buffer, num_out of them, and mainline's trailing gfp_t
526 * (not the `void *ctx` DCL's add_inbuf carries). The
527 * distinction matters at the two call sites, which pass
528 * GFP_ATOMIC == 1: an int 1 into a `void *` parameter is
529 * a constraint violation, and it would have been reported
530 * as an implicit-conversion error at every call rather
531 * than at the declaration.
532 * disable_cb/enable_cb mask and unmask used-buffer notifications. Neither
533 * has a call site in this driver *today* -- the four
534 * virtqueue_disable_cb() calls all sit inside
535 * virtcons_freeze(), which #ifdef CONFIG_PM_SLEEP removes
536 * (and DCL sets no such config) -- which is why they are
537 * declared and not defined: a body nothing can reach is
538 * one more thing to get wrong for no caller, and the
539 * next driver that uncomments a suspend path will find
540 * the declaration where mainline puts it rather than an
541 * implicit-int error.
542 * detach_unused_buf returns a buffer still owned by the queue so it can be
543 * freed; NULL when there is none, which is the whole of
544 * remove_vqs()'s inner loop condition.
545 * is_broken a queue whose device went away. DCL's is always false:
546 * there is no removal path to break a queue, and a
547 * `while (!virtqueue_get_buf() && !is_broken()) cpu_relax()`
548 * spin that could never exit on the second condition is
549 * exactly the loop it should be -- it exits on the first.
550 */
551int virtqueue_add_outbuf(struct virtqueue* vq, struct scatterlist sg[],
552 unsigned int num, void* data, gfp_t gfp);
556bool virtqueue_is_broken(const struct virtqueue* vq);
557
558/*
559 * virtio_break_device() -- mark the device's queues broken so callers stop
560 * waiting on them. mainline: drivers/virtio/virtio.c, and it is the one
561 * virtio entry point with no DCL implementation behind it until now.
562 *
563 * DCL's body marks the device's live queues, which is what the one caller
564 * (virtio_console.c:1920, the probe-failure unwind) wants: after it runs,
565 * every `while (... && !virtqueue_is_broken(vq))` in the driver stops
566 * spinning. Declared here rather than in <linux/virtio_config.h> because
567 * mainline declares it in <linux/virtio.h>, which is this file.
568 */
570
572 struct VirtioPCIDevice* au_dev,
573 int dev_index);
574
575#endif
#define bool
Definition stdbool.h:35
#define index(str, chr)
Definition string.h:66
unsigned short int uint16_t
Definition acefiex.h:162
#define NULL
Definition actypes.h:561
uint32_t __u32
Definition drm.h:42
size_t size_t offset
Definition drm_bridge.h:1299
struct drm_crtc struct drm_plane struct drm_plane const struct drm_crtc_funcs const char * name
Definition drm_crtc.h:1242
const struct device * dev
Definition drm_print.h:519
size_t len
Definition initial.c:23
void virtio_device_register(void)
void virtio_reset_device(void)
void register_virtio_driver(void)
void virtqueue_get_buf(void)
void memcpy(void)
void unregister_virtio_driver(void)
void virtqueue_add_inbuf(void)
void virtqueue_kick(void)
void * data
Definition kthread.h:30
uint64_t u64
Definition kernel.h:17
uint8_t u8
Definition kernel.h:14
unsigned int gfp_t
Definition kernel.h:56
uint32_t u32
Definition kernel.h:16
unsigned int virtqueue_get_vring_size(const struct virtqueue *vq)
struct virtqueue * virtio_find_single_vq(struct virtio_device *vdev, void(*cb)(struct virtqueue *vq), const char *name)
int virtqueue_add_inbuf_cache_clean(struct virtqueue *vq, struct scatterlist *sg, unsigned int num_in, void *data, gfp_t gfp)
int virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs, struct virtqueue **vqs, struct virtqueue_info *vqs_info, void *desc)
void virtio_break_device(struct virtio_device *dev)
void virtio_poll_input_vqs(void)
bool virtqueue_is_broken(const struct virtqueue *vq)
void virtio_del_vqs(struct virtio_device *vdev)
int virtio_input_detect(void)
int virtqueue_add_sgs(struct virtqueue *vq, struct scatterlist *sgs[], unsigned int out_cnt, unsigned int in_cnt, void *data, gfp_t gfp)
void virtqueue_notify(struct virtqueue *vq)
void virtio_rng_detect(void)
int virtqueue_add_outbuf(struct virtqueue *vq, struct scatterlist sg[], unsigned int num, void *data, gfp_t gfp)
void virtio_poll_vqs(void)
void virtqueue_disable_cb(struct virtqueue *vq)
void * virtqueue_detach_unused_buf(struct virtqueue *vq)
bool virtqueue_enable_cb(struct virtqueue *vq)
bool virtqueue_kick_prepare(struct virtqueue *vq)
void virtio_device_ready(struct virtio_device *vdev)
a mapped, reset-and-negotiated modern virtio-pci device. Per-device drivers build their own virtqueue...
Definition virtio.h:222
Definition virtio.h:201
Definition virtio.h:194
Definition virtio.h:212
Definition driver.h:39
Definition fs.h:255
Definition list.h:11
Definition scatterlist.h:73
Definition virtio.h:115
void * device_config_base
Definition virtio.h:139
void(* reset)(struct virtio_device *vdev)
Definition virtio.h:121
void(* get_extended_features)(struct virtio_device *vdev, u64 *features)
Definition virtio.h:130
int(* find_vqs)(struct virtio_device *vdev, unsigned nvqs, struct virtqueue **vqs, struct virtqueue_info *vqs_info, void *desc)
Definition virtio.h:122
void(* set_status)(struct virtio_device *vdev, u8 status)
Definition virtio.h:120
u64(* get_features)(struct virtio_device *vdev)
Definition virtio.h:129
int(* disable_vq_and_reset)(struct virtqueue *vq)
Definition virtio.h:136
u8(* get_status)(struct virtio_device *vdev)
Definition virtio.h:119
u32(* generation)(struct virtio_device *vdev)
Definition virtio.h:118
bool(* get_shm_region)(struct virtio_device *vdev, void *region, u8 id)
Definition virtio.h:135
void(* del_vqs)(struct virtio_device *vdev)
Definition virtio.h:127
void(* synchronize_cbs)(struct virtio_device *vdev)
Definition virtio.h:128
int(* enable_vq_after_reset)(struct virtqueue *vq)
Definition virtio.h:137
void(* get)(struct virtio_device *vdev, unsigned offset, void *buf, unsigned len)
Definition virtio.h:116
void(* set)(struct virtio_device *vdev, unsigned offset, const void *buf, unsigned len)
Definition virtio.h:117
int(* set_vq_affinity)(struct virtqueue *vq, const void *cpu_mask)
Definition virtio.h:133
int(* finalize_features)(struct virtio_device *vdev)
Definition virtio.h:131
Definition virtio.h:152
__u32 vendor
Definition virtio.h:154
__u32 device
Definition virtio.h:153
Definition virtio.h:157
struct VirtioPCIDevice * au_dev
Definition virtio.h:164
void * priv
Definition virtio.h:163
int index
Definition virtio.h:158
struct device dev
Definition virtio.h:204
struct list_head vqs
Definition virtio.h:205
unsigned char _linux_prefix[0x328]
Definition virtio.h:160
void * drv_data
Definition virtio.h:159
struct virtio_config_ops * config
Definition virtio.h:161
struct virtio_device_id id
Definition virtio.h:203
unsigned char _mid[0x30]
Definition virtio.h:162
Definition virtio.h:222
int(* restore)(struct virtio_device *vdev)
Definition virtio.h:277
int(* validate)(struct virtio_device *vdev)
Definition virtio.h:263
int(* probe)(struct virtio_device *vdev)
Definition virtio.h:264
unsigned int feature_table_size
Definition virtio.h:260
void(* remove)(struct virtio_device *vdev)
Definition virtio.h:266
void(* scan)(struct virtio_device *vdev)
Definition virtio.h:265
unsigned int feature_table_size_legacy
Definition virtio.h:262
const unsigned int * feature_table_legacy
Definition virtio.h:261
void(* shutdown)(struct virtio_device *vdev)
Definition virtio.h:275
const unsigned int * feature_table
Definition virtio.h:259
int(* freeze)(struct virtio_device *vdev)
Definition virtio.h:276
const struct virtio_device_id * id_table
Definition virtio.h:228
struct device_driver driver
Definition virtio.h:227
void(* config_changed)(struct virtio_device *vdev)
Definition virtio.h:267
Definition virtio.h:108
const char * name
Definition virtio.h:109
bool ctx
Definition virtio.h:111
void(* callback)(struct virtqueue *vq)
Definition virtio.h:110
Definition virtio.h:280
void * cookies[256]
Definition virtio.h:292
struct list_head list
Definition virtio.h:316
unsigned char _linux_prefix[32]
Definition virtio.h:281
void(* callback)(struct virtqueue *vq)
Definition virtio.h:291
struct VirtqUsedHdr * used
Definition virtio.h:285
const char * name
Definition virtio.h:290
uint16_t num_free
Definition virtio.h:287
uint16_t event_idx_write
Definition virtio.h:293
uint16_t index
Definition virtio.h:288
struct VirtqAvailHdr * avail
Definition virtio.h:284
uint16_t free_head
Definition virtio.h:286
bool broken
Definition virtio.h:303
struct virtio_device * vdev
Definition virtio.h:282
uint16_t qsize
Definition virtio.h:289
struct VirtqDesc * desc
Definition virtio.h:283