Import QEMU upstream snapshot d2e570c
Upstream: https://gitlab.com/qemu-project/qemu.git Upstream-Commit: d2e570cc0f97b936902a5b1b86b73c0f5998b475
This commit is contained in:
commit
cf256aa081
11315 files changed
+3598369
No files matched your search
@@ -0,0 +1,71 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
/* const.h: Macros for dealing with constants. */
|
||||
|
||||
#ifndef _LINUX_CONST_H
|
||||
#define _LINUX_CONST_H
|
||||
|
||||
/* Some constant macros are used in both assembler and
|
||||
* C code. Therefore we cannot annotate them always with
|
||||
* 'UL' and other type specifiers unilaterally. We
|
||||
* use the following macros to deal with this.
|
||||
*
|
||||
* Similarly, _AT() will cast an expression with a type in C, but
|
||||
* leave it unchanged in asm.
|
||||
*/
|
||||
|
||||
#ifdef __ASSEMBLER__
|
||||
#define _AC(X,Y) X
|
||||
#define _AT(T,X) X
|
||||
#else
|
||||
#define __AC(X,Y) (X##Y)
|
||||
#define _AC(X,Y) __AC(X,Y)
|
||||
#define _AT(T,X) ((T)(X))
|
||||
#endif
|
||||
|
||||
#define _UL(x) (_AC(x, UL))
|
||||
#define _ULL(x) (_AC(x, ULL))
|
||||
|
||||
#define _BITUL(x) (_UL(1) << (x))
|
||||
#define _BITULL(x) (_ULL(1) << (x))
|
||||
|
||||
#if !defined(__ASSEMBLER__)
|
||||
/*
|
||||
* Missing __asm__ support
|
||||
*
|
||||
* __BIT128() would not work in the __asm__ code, as it shifts an
|
||||
* 'unsigned __int128' data type as direct representation of
|
||||
* 128 bit constants is not supported in the gcc compiler, as
|
||||
* they get silently truncated.
|
||||
*
|
||||
* TODO: Please revisit this implementation when gcc compiler
|
||||
* starts representing 128 bit constants directly like long
|
||||
* and unsigned long etc. Subsequently drop the comment for
|
||||
* GENMASK_U128() which would then start supporting __asm__ code.
|
||||
*/
|
||||
#define _BIT128(x) ((unsigned __int128)(1) << (x))
|
||||
#endif
|
||||
|
||||
#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
|
||||
#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
|
||||
|
||||
#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
|
||||
|
||||
/*
|
||||
* Divide positive or negative dividend by positive or negative divisor
|
||||
* and round to closest integer. Result is undefined for negative
|
||||
* divisors if the dividend variable type is unsigned and for negative
|
||||
* dividends if the divisor variable type is unsigned.
|
||||
*/
|
||||
#define __KERNEL_DIV_ROUND_CLOSEST(x, divisor) \
|
||||
({ \
|
||||
__typeof__(x) __x = x; \
|
||||
__typeof__(divisor) __d = divisor; \
|
||||
\
|
||||
(((__typeof__(x))-1) > 0 || \
|
||||
((__typeof__(divisor))-1) > 0 || \
|
||||
(((__x) > 0) == ((__d) > 0))) ? \
|
||||
(((__x) + ((__d) / 2)) / (__d)) : \
|
||||
(((__x) - ((__d) / 2)) / (__d)); \
|
||||
})
|
||||
|
||||
#endif /* _LINUX_CONST_H */
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1 @@
|
||||
#define ETH_ALEN 6
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,536 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
/*
|
||||
* Copyright (c) 1999-2002 Vojtech Pavlik
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 as published by
|
||||
* the Free Software Foundation.
|
||||
*/
|
||||
#ifndef _INPUT_H
|
||||
#define _INPUT_H
|
||||
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
#include "standard-headers/linux/input-event-codes.h"
|
||||
|
||||
/*
|
||||
* The event structure itself
|
||||
* Note that __USE_TIME_BITS64 is defined by libc based on
|
||||
* application's request to use 64 bit time_t.
|
||||
*/
|
||||
|
||||
struct input_event {
|
||||
#if (HOST_LONG_BITS != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL__)
|
||||
struct timeval time;
|
||||
#define input_event_sec time.tv_sec
|
||||
#define input_event_usec time.tv_usec
|
||||
#else
|
||||
unsigned long __sec;
|
||||
#if defined(__sparc__) && defined(__arch64__)
|
||||
unsigned int __usec;
|
||||
unsigned int __pad;
|
||||
#else
|
||||
unsigned long __usec;
|
||||
#endif
|
||||
#define input_event_sec __sec
|
||||
#define input_event_usec __usec
|
||||
#endif
|
||||
uint16_t type;
|
||||
uint16_t code;
|
||||
int32_t value;
|
||||
};
|
||||
|
||||
/*
|
||||
* Protocol version.
|
||||
*/
|
||||
|
||||
#define EV_VERSION 0x010001
|
||||
|
||||
/*
|
||||
* IOCTLs (0x00 - 0x7f)
|
||||
*/
|
||||
|
||||
struct input_id {
|
||||
uint16_t bustype;
|
||||
uint16_t vendor;
|
||||
uint16_t product;
|
||||
uint16_t version;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct input_absinfo - used by EVIOCGABS/EVIOCSABS ioctls
|
||||
* @value: latest reported value for the axis.
|
||||
* @minimum: specifies minimum value for the axis.
|
||||
* @maximum: specifies maximum value for the axis.
|
||||
* @fuzz: specifies fuzz value that is used to filter noise from
|
||||
* the event stream.
|
||||
* @flat: values that are within this value will be discarded by
|
||||
* joydev interface and reported as 0 instead.
|
||||
* @resolution: specifies resolution for the values reported for
|
||||
* the axis.
|
||||
*
|
||||
* Note that input core does not clamp reported values to the
|
||||
* [minimum, maximum] limits, such task is left to userspace.
|
||||
*
|
||||
* The default resolution for main axes (ABS_X, ABS_Y, ABS_Z,
|
||||
* ABS_MT_POSITION_X, ABS_MT_POSITION_Y) is reported in units
|
||||
* per millimeter (units/mm), resolution for rotational axes
|
||||
* (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian.
|
||||
* The resolution for the size axes (ABS_MT_TOUCH_MAJOR,
|
||||
* ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MAJOR, ABS_MT_WIDTH_MINOR)
|
||||
* is reported in units per millimeter (units/mm).
|
||||
* When INPUT_PROP_ACCELEROMETER is set the resolution changes.
|
||||
* The main axes (ABS_X, ABS_Y, ABS_Z) are then reported in
|
||||
* units per g (units/g) and in units per degree per second
|
||||
* (units/deg/s) for rotational axes (ABS_RX, ABS_RY, ABS_RZ).
|
||||
*/
|
||||
struct input_absinfo {
|
||||
int32_t value;
|
||||
int32_t minimum;
|
||||
int32_t maximum;
|
||||
int32_t fuzz;
|
||||
int32_t flat;
|
||||
int32_t resolution;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls
|
||||
* @scancode: scancode represented in machine-endian form.
|
||||
* @len: length of the scancode that resides in @scancode buffer.
|
||||
* @index: index in the keymap, may be used instead of scancode
|
||||
* @flags: allows to specify how kernel should handle the request. For
|
||||
* example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel
|
||||
* should perform lookup in keymap by @index instead of @scancode
|
||||
* @keycode: key code assigned to this scancode
|
||||
*
|
||||
* The structure is used to retrieve and modify keymap data. Users have
|
||||
* option of performing lookup either by @scancode itself or by @index
|
||||
* in keymap entry. EVIOCGKEYCODE will also return scancode or index
|
||||
* (depending on which element was used to perform lookup).
|
||||
*/
|
||||
struct input_keymap_entry {
|
||||
#define INPUT_KEYMAP_BY_INDEX (1 << 0)
|
||||
uint8_t flags;
|
||||
uint8_t len;
|
||||
uint16_t index;
|
||||
uint32_t keycode;
|
||||
uint8_t scancode[32];
|
||||
};
|
||||
|
||||
struct input_mask {
|
||||
uint32_t type;
|
||||
uint32_t codes_size;
|
||||
uint64_t codes_ptr;
|
||||
};
|
||||
|
||||
#define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */
|
||||
#define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */
|
||||
#define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */
|
||||
#define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */
|
||||
|
||||
#define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */
|
||||
#define EVIOCGKEYCODE_V2 _IOR('E', 0x04, struct input_keymap_entry)
|
||||
#define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2]) /* set keycode */
|
||||
#define EVIOCSKEYCODE_V2 _IOW('E', 0x04, struct input_keymap_entry)
|
||||
|
||||
#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */
|
||||
#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */
|
||||
#define EVIOCGUNIQ(len) _IOC(_IOC_READ, 'E', 0x08, len) /* get unique identifier */
|
||||
#define EVIOCGPROP(len) _IOC(_IOC_READ, 'E', 0x09, len) /* get device properties */
|
||||
|
||||
/**
|
||||
* EVIOCGMTSLOTS(len) - get MT slot values
|
||||
* @len: size of the data buffer in bytes
|
||||
*
|
||||
* The ioctl buffer argument should be binary equivalent to
|
||||
*
|
||||
* struct input_mt_request_layout {
|
||||
* uint32_t code;
|
||||
* int32_t values[num_slots];
|
||||
* };
|
||||
*
|
||||
* where num_slots is the (arbitrary) number of MT slots to extract.
|
||||
*
|
||||
* The ioctl size argument (len) is the size of the buffer, which
|
||||
* should satisfy len = (num_slots + 1) * sizeof(int32_t). If len is
|
||||
* too small to fit all available slots, the first num_slots are
|
||||
* returned.
|
||||
*
|
||||
* Before the call, code is set to the wanted ABS_MT event type. On
|
||||
* return, values[] is filled with the slot values for the specified
|
||||
* ABS_MT code.
|
||||
*
|
||||
* If the request code is not an ABS_MT value, -EINVAL is returned.
|
||||
*/
|
||||
#define EVIOCGMTSLOTS(len) _IOC(_IOC_READ, 'E', 0x0a, len)
|
||||
|
||||
#define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global key state */
|
||||
#define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */
|
||||
#define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */
|
||||
#define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */
|
||||
|
||||
#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + (ev), len) /* get event bits */
|
||||
#define EVIOCGABS(abs) _IOR('E', 0x40 + (abs), struct input_absinfo) /* get abs value/limits */
|
||||
#define EVIOCSABS(abs) _IOW('E', 0xc0 + (abs), struct input_absinfo) /* set abs value/limits */
|
||||
|
||||
#define EVIOCSFF _IOW('E', 0x80, struct ff_effect) /* send a force effect to a force feedback device */
|
||||
#define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */
|
||||
#define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */
|
||||
|
||||
#define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */
|
||||
#define EVIOCREVOKE _IOW('E', 0x91, int) /* Revoke device access */
|
||||
|
||||
/**
|
||||
* EVIOCGMASK - Retrieve current event mask
|
||||
*
|
||||
* This ioctl allows user to retrieve the current event mask for specific
|
||||
* event type. The argument must be of type "struct input_mask" and
|
||||
* specifies the event type to query, the address of the receive buffer and
|
||||
* the size of the receive buffer.
|
||||
*
|
||||
* The event mask is a per-client mask that specifies which events are
|
||||
* forwarded to the client. Each event code is represented by a single bit
|
||||
* in the event mask. If the bit is set, the event is passed to the client
|
||||
* normally. Otherwise, the event is filtered and will never be queued on
|
||||
* the client's receive buffer.
|
||||
*
|
||||
* Event masks do not affect global state of the input device. They only
|
||||
* affect the file descriptor they are applied to.
|
||||
*
|
||||
* The default event mask for a client has all bits set, i.e. all events
|
||||
* are forwarded to the client. If the kernel is queried for an unknown
|
||||
* event type or if the receive buffer is larger than the number of
|
||||
* event codes known to the kernel, the kernel returns all zeroes for those
|
||||
* codes.
|
||||
*
|
||||
* At maximum, codes_size bytes are copied.
|
||||
*
|
||||
* This ioctl may fail with ENODEV in case the file is revoked, EFAULT
|
||||
* if the receive-buffer points to invalid memory, or EINVAL if the kernel
|
||||
* does not implement the ioctl.
|
||||
*/
|
||||
#define EVIOCGMASK _IOR('E', 0x92, struct input_mask) /* Get event-masks */
|
||||
|
||||
/**
|
||||
* EVIOCSMASK - Set event mask
|
||||
*
|
||||
* This ioctl is the counterpart to EVIOCGMASK. Instead of receiving the
|
||||
* current event mask, this changes the client's event mask for a specific
|
||||
* type. See EVIOCGMASK for a description of event-masks and the
|
||||
* argument-type.
|
||||
*
|
||||
* This ioctl provides full forward compatibility. If the passed event type
|
||||
* is unknown to the kernel, or if the number of event codes specified in
|
||||
* the mask is bigger than what is known to the kernel, the ioctl is still
|
||||
* accepted and applied. However, any unknown codes are left untouched and
|
||||
* stay cleared. That means, the kernel always filters unknown codes
|
||||
* regardless of what the client requests. If the new mask doesn't cover
|
||||
* all known event-codes, all remaining codes are automatically cleared and
|
||||
* thus filtered.
|
||||
*
|
||||
* This ioctl may fail with ENODEV in case the file is revoked. EFAULT is
|
||||
* returned if the receive-buffer points to invalid memory. EINVAL is returned
|
||||
* if the kernel does not implement the ioctl.
|
||||
*/
|
||||
#define EVIOCSMASK _IOW('E', 0x93, struct input_mask) /* Set event-masks */
|
||||
|
||||
#define EVIOCSCLOCKID _IOW('E', 0xa0, int) /* Set clockid to be used for timestamps */
|
||||
|
||||
/*
|
||||
* IDs.
|
||||
*/
|
||||
|
||||
#define ID_BUS 0
|
||||
#define ID_VENDOR 1
|
||||
#define ID_PRODUCT 2
|
||||
#define ID_VERSION 3
|
||||
|
||||
#define BUS_PCI 0x01
|
||||
#define BUS_ISAPNP 0x02
|
||||
#define BUS_USB 0x03
|
||||
#define BUS_HIL 0x04
|
||||
#define BUS_BLUETOOTH 0x05
|
||||
#define BUS_VIRTUAL 0x06
|
||||
|
||||
#define BUS_ISA 0x10
|
||||
#define BUS_I8042 0x11
|
||||
#define BUS_XTKBD 0x12
|
||||
#define BUS_RS232 0x13
|
||||
#define BUS_GAMEPORT 0x14
|
||||
#define BUS_PARPORT 0x15
|
||||
#define BUS_AMIGA 0x16
|
||||
#define BUS_ADB 0x17
|
||||
#define BUS_I2C 0x18
|
||||
#define BUS_HOST 0x19
|
||||
#define BUS_GSC 0x1A
|
||||
#define BUS_ATARI 0x1B
|
||||
#define BUS_SPI 0x1C
|
||||
#define BUS_RMI 0x1D
|
||||
#define BUS_CEC 0x1E
|
||||
#define BUS_INTEL_ISHTP 0x1F
|
||||
#define BUS_AMD_SFH 0x20
|
||||
#define BUS_SDW 0x21
|
||||
|
||||
/*
|
||||
* MT_TOOL types
|
||||
*/
|
||||
#define MT_TOOL_FINGER 0x00
|
||||
#define MT_TOOL_PEN 0x01
|
||||
#define MT_TOOL_PALM 0x02
|
||||
#define MT_TOOL_DIAL 0x0a
|
||||
#define MT_TOOL_MAX 0x0f
|
||||
|
||||
/*
|
||||
* Values describing the status of a force-feedback effect
|
||||
*/
|
||||
#define FF_STATUS_STOPPED 0x00
|
||||
#define FF_STATUS_PLAYING 0x01
|
||||
#define FF_STATUS_MAX 0x01
|
||||
|
||||
/*
|
||||
* Structures used in ioctls to upload effects to a device
|
||||
* They are pieces of a bigger structure (called ff_effect)
|
||||
*/
|
||||
|
||||
/*
|
||||
* All duration values are expressed in ms. Values above 32767 ms (0x7fff)
|
||||
* should not be used and have unspecified results.
|
||||
*/
|
||||
|
||||
/**
|
||||
* struct ff_replay - defines scheduling of the force-feedback effect
|
||||
* @length: duration of the effect
|
||||
* @delay: delay before effect should start playing
|
||||
*/
|
||||
struct ff_replay {
|
||||
uint16_t length;
|
||||
uint16_t delay;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ff_trigger - defines what triggers the force-feedback effect
|
||||
* @button: number of the button triggering the effect
|
||||
* @interval: controls how soon the effect can be re-triggered
|
||||
*/
|
||||
struct ff_trigger {
|
||||
uint16_t button;
|
||||
uint16_t interval;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ff_envelope - generic force-feedback effect envelope
|
||||
* @attack_length: duration of the attack (ms)
|
||||
* @attack_level: level at the beginning of the attack
|
||||
* @fade_length: duration of fade (ms)
|
||||
* @fade_level: level at the end of fade
|
||||
*
|
||||
* The @attack_level and @fade_level are absolute values; when applying
|
||||
* envelope force-feedback core will convert to positive/negative
|
||||
* value based on polarity of the default level of the effect.
|
||||
* Valid range for the attack and fade levels is 0x0000 - 0x7fff
|
||||
*/
|
||||
struct ff_envelope {
|
||||
uint16_t attack_length;
|
||||
uint16_t attack_level;
|
||||
uint16_t fade_length;
|
||||
uint16_t fade_level;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ff_constant_effect - defines parameters of a constant force-feedback effect
|
||||
* @level: strength of the effect; may be negative
|
||||
* @envelope: envelope data
|
||||
*/
|
||||
struct ff_constant_effect {
|
||||
int16_t level;
|
||||
struct ff_envelope envelope;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ff_ramp_effect - defines parameters of a ramp force-feedback effect
|
||||
* @start_level: beginning strength of the effect; may be negative
|
||||
* @end_level: final strength of the effect; may be negative
|
||||
* @envelope: envelope data
|
||||
*/
|
||||
struct ff_ramp_effect {
|
||||
int16_t start_level;
|
||||
int16_t end_level;
|
||||
struct ff_envelope envelope;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ff_condition_effect - defines a spring or friction force-feedback effect
|
||||
* @right_saturation: maximum level when joystick moved all way to the right
|
||||
* @left_saturation: same for the left side
|
||||
* @right_coeff: controls how fast the force grows when the joystick moves
|
||||
* to the right
|
||||
* @left_coeff: same for the left side
|
||||
* @deadband: size of the dead zone, where no force is produced
|
||||
* @center: position of the dead zone
|
||||
*/
|
||||
struct ff_condition_effect {
|
||||
uint16_t right_saturation;
|
||||
uint16_t left_saturation;
|
||||
|
||||
int16_t right_coeff;
|
||||
int16_t left_coeff;
|
||||
|
||||
uint16_t deadband;
|
||||
int16_t center;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ff_periodic_effect - defines parameters of a periodic force-feedback effect
|
||||
* @waveform: kind of the effect (wave)
|
||||
* @period: period of the wave (ms)
|
||||
* @magnitude: peak value
|
||||
* @offset: mean value of the wave (roughly)
|
||||
* @phase: 'horizontal' shift
|
||||
* @envelope: envelope data
|
||||
* @custom_len: number of samples (FF_CUSTOM only)
|
||||
* @custom_data: buffer of samples (FF_CUSTOM only)
|
||||
*
|
||||
* Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP,
|
||||
* FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined
|
||||
* for the time being as no driver supports it yet.
|
||||
*
|
||||
* Note: the data pointed by custom_data is copied by the driver.
|
||||
* You can therefore dispose of the memory after the upload/update.
|
||||
*/
|
||||
struct ff_periodic_effect {
|
||||
uint16_t waveform;
|
||||
uint16_t period;
|
||||
int16_t magnitude;
|
||||
int16_t offset;
|
||||
uint16_t phase;
|
||||
|
||||
struct ff_envelope envelope;
|
||||
|
||||
uint32_t custom_len;
|
||||
int16_t *custom_data;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ff_rumble_effect - defines parameters of a periodic force-feedback effect
|
||||
* @strong_magnitude: magnitude of the heavy motor
|
||||
* @weak_magnitude: magnitude of the light one
|
||||
*
|
||||
* Some rumble pads have two motors of different weight. Strong_magnitude
|
||||
* represents the magnitude of the vibration generated by the heavy one.
|
||||
*/
|
||||
struct ff_rumble_effect {
|
||||
uint16_t strong_magnitude;
|
||||
uint16_t weak_magnitude;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ff_haptic_effect
|
||||
* @hid_usage: hid_usage according to Haptics page (WAVEFORM_CLICK, etc.)
|
||||
* @vendor_id: the waveform vendor ID if hid_usage is in the vendor-defined range
|
||||
* @vendor_waveform_page: the vendor waveform page if hid_usage is in the vendor-defined range
|
||||
* @intensity: strength of the effect as percentage
|
||||
* @repeat_count: number of times to retrigger effect
|
||||
* @retrigger_period: time before effect is retriggered (in ms)
|
||||
*/
|
||||
struct ff_haptic_effect {
|
||||
uint16_t hid_usage;
|
||||
uint16_t vendor_id;
|
||||
uint8_t vendor_waveform_page;
|
||||
uint16_t intensity;
|
||||
uint16_t repeat_count;
|
||||
uint16_t retrigger_period;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ff_effect - defines force feedback effect
|
||||
* @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING,
|
||||
* FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM)
|
||||
* @id: an unique id assigned to an effect
|
||||
* @direction: direction of the effect
|
||||
* @trigger: trigger conditions (struct ff_trigger)
|
||||
* @replay: scheduling of the effect (struct ff_replay)
|
||||
* @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect,
|
||||
* ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further
|
||||
* defining effect parameters
|
||||
*
|
||||
* This structure is sent through ioctl from the application to the driver.
|
||||
* To create a new effect application should set its @id to -1; the kernel
|
||||
* will return assigned @id which can later be used to update or delete
|
||||
* this effect.
|
||||
*
|
||||
* Direction of the effect is encoded as follows:
|
||||
* 0 deg -> 0x0000 (down)
|
||||
* 90 deg -> 0x4000 (left)
|
||||
* 180 deg -> 0x8000 (up)
|
||||
* 270 deg -> 0xC000 (right)
|
||||
*/
|
||||
struct ff_effect {
|
||||
uint16_t type;
|
||||
int16_t id;
|
||||
uint16_t direction;
|
||||
struct ff_trigger trigger;
|
||||
struct ff_replay replay;
|
||||
|
||||
union {
|
||||
struct ff_constant_effect constant;
|
||||
struct ff_ramp_effect ramp;
|
||||
struct ff_periodic_effect periodic;
|
||||
struct ff_condition_effect condition[2]; /* One for each axis */
|
||||
struct ff_rumble_effect rumble;
|
||||
struct ff_haptic_effect haptic;
|
||||
} u;
|
||||
};
|
||||
|
||||
/*
|
||||
* Force feedback effect types
|
||||
*/
|
||||
|
||||
#define FF_HAPTIC 0x4f
|
||||
#define FF_RUMBLE 0x50
|
||||
#define FF_PERIODIC 0x51
|
||||
#define FF_CONSTANT 0x52
|
||||
#define FF_SPRING 0x53
|
||||
#define FF_FRICTION 0x54
|
||||
#define FF_DAMPER 0x55
|
||||
#define FF_INERTIA 0x56
|
||||
#define FF_RAMP 0x57
|
||||
|
||||
#define FF_EFFECT_MIN FF_HAPTIC
|
||||
#define FF_EFFECT_MAX FF_RAMP
|
||||
|
||||
/*
|
||||
* Force feedback periodic effect types
|
||||
*/
|
||||
|
||||
#define FF_SQUARE 0x58
|
||||
#define FF_TRIANGLE 0x59
|
||||
#define FF_SINE 0x5a
|
||||
#define FF_SAW_UP 0x5b
|
||||
#define FF_SAW_DOWN 0x5c
|
||||
#define FF_CUSTOM 0x5d
|
||||
|
||||
#define FF_WAVEFORM_MIN FF_SQUARE
|
||||
#define FF_WAVEFORM_MAX FF_CUSTOM
|
||||
|
||||
/*
|
||||
* Set ff device properties
|
||||
*/
|
||||
|
||||
#define FF_GAIN 0x60
|
||||
#define FF_AUTOCENTER 0x61
|
||||
|
||||
/*
|
||||
* ff->playback(effect_id = FF_GAIN) is the first effect_id to
|
||||
* cause a collision with another ff method, in this case ff->set_gain().
|
||||
* Therefore the greatest safe value for effect_id is FF_GAIN - 1,
|
||||
* and thus the total number of effects should never exceed FF_GAIN.
|
||||
*/
|
||||
#define FF_MAX_EFFECTS FF_GAIN
|
||||
|
||||
#define FF_MAX 0x7f
|
||||
#define FF_CNT (FF_MAX+1)
|
||||
|
||||
#endif /* _INPUT_H */
|
||||
@@ -0,0 +1,8 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
#ifndef _LINUX_KERNEL_H
|
||||
#define _LINUX_KERNEL_H
|
||||
|
||||
#include "standard-headers/linux/sysinfo.h"
|
||||
#include "standard-headers/linux/const.h"
|
||||
|
||||
#endif /* _LINUX_KERNEL_H */
|
||||
@@ -0,0 +1,38 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
#ifndef __LINUX_KVM_PARA_H
|
||||
#define __LINUX_KVM_PARA_H
|
||||
|
||||
/*
|
||||
* This header file provides a method for making a hypercall to the host
|
||||
* Architectures should define:
|
||||
* - kvm_hypercall0, kvm_hypercall1...
|
||||
* - kvm_arch_para_features
|
||||
* - kvm_para_available
|
||||
*/
|
||||
|
||||
/* Return values for hypercalls */
|
||||
#define KVM_ENOSYS 1000
|
||||
#define KVM_EFAULT EFAULT
|
||||
#define KVM_EINVAL EINVAL
|
||||
#define KVM_E2BIG E2BIG
|
||||
#define KVM_EPERM EPERM
|
||||
#define KVM_EOPNOTSUPP 95
|
||||
|
||||
#define KVM_HC_VAPIC_POLL_IRQ 1
|
||||
#define KVM_HC_MMU_OP 2
|
||||
#define KVM_HC_FEATURES 3
|
||||
#define KVM_HC_PPC_MAP_MAGIC_PAGE 4
|
||||
#define KVM_HC_KICK_CPU 5
|
||||
#define KVM_HC_MIPS_GET_CLOCK_FREQ 6
|
||||
#define KVM_HC_MIPS_EXIT_VM 7
|
||||
#define KVM_HC_MIPS_CONSOLE_OUTPUT 8
|
||||
#define KVM_HC_CLOCK_PAIRING 9
|
||||
#define KVM_HC_SEND_IPI 10
|
||||
#define KVM_HC_SCHED_YIELD 11
|
||||
#define KVM_HC_MAP_GPA_RANGE 12
|
||||
|
||||
/*
|
||||
* hypercalls use architecture specific
|
||||
*/
|
||||
|
||||
#endif /* __LINUX_KVM_PARA_H */
|
||||
@@ -0,0 +1,359 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
/*
|
||||
* Copyright 2020-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_NITRO_ENCLAVES_H_
|
||||
#define _LINUX_NITRO_ENCLAVES_H_
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
/**
|
||||
* DOC: Nitro Enclaves (NE) Kernel Driver Interface
|
||||
*/
|
||||
|
||||
/**
|
||||
* NE_CREATE_VM - The command is used to create a slot that is associated with
|
||||
* an enclave VM.
|
||||
* The generated unique slot id is an output parameter.
|
||||
* The ioctl can be invoked on the /dev/nitro_enclaves fd, before
|
||||
* setting any resources, such as memory and vCPUs, for an
|
||||
* enclave. Memory and vCPUs are set for the slot mapped to an enclave.
|
||||
* A NE CPU pool has to be set before calling this function. The
|
||||
* pool can be set after the NE driver load, using
|
||||
* /sys/module/nitro_enclaves/parameters/ne_cpus.
|
||||
* Its format is the detailed in the cpu-lists section:
|
||||
* https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
|
||||
* CPU 0 and its siblings have to remain available for the
|
||||
* primary / parent VM, so they cannot be set for enclaves. Full
|
||||
* CPU core(s), from the same NUMA node, need(s) to be included
|
||||
* in the CPU pool.
|
||||
*
|
||||
* Context: Process context.
|
||||
* Return:
|
||||
* * Enclave file descriptor - Enclave file descriptor used with
|
||||
* ioctl calls to set vCPUs and memory
|
||||
* regions, then start the enclave.
|
||||
* * -1 - There was a failure in the ioctl logic.
|
||||
* On failure, errno is set to:
|
||||
* * EFAULT - copy_to_user() failure.
|
||||
* * ENOMEM - Memory allocation failure for internal
|
||||
* bookkeeping variables.
|
||||
* * NE_ERR_NO_CPUS_AVAIL_IN_POOL - No NE CPU pool set / no CPUs available
|
||||
* in the pool.
|
||||
* * Error codes from get_unused_fd_flags() and anon_inode_getfile().
|
||||
* * Error codes from the NE PCI device request.
|
||||
*/
|
||||
#define NE_CREATE_VM _IOR(0xAE, 0x20, uint64_t)
|
||||
|
||||
/**
|
||||
* NE_ADD_VCPU - The command is used to set a vCPU for an enclave. The vCPU can
|
||||
* be auto-chosen from the NE CPU pool or it can be set by the
|
||||
* caller, with the note that it needs to be available in the NE
|
||||
* CPU pool. Full CPU core(s), from the same NUMA node, need(s) to
|
||||
* be associated with an enclave.
|
||||
* The vCPU id is an input / output parameter. If its value is 0,
|
||||
* then a CPU is chosen from the enclave CPU pool and returned via
|
||||
* this parameter.
|
||||
* The ioctl can be invoked on the enclave fd, before an enclave
|
||||
* is started.
|
||||
*
|
||||
* Context: Process context.
|
||||
* Return:
|
||||
* * 0 - Logic successfully completed.
|
||||
* * -1 - There was a failure in the ioctl logic.
|
||||
* On failure, errno is set to:
|
||||
* * EFAULT - copy_from_user() / copy_to_user() failure.
|
||||
* * ENOMEM - Memory allocation failure for internal
|
||||
* bookkeeping variables.
|
||||
* * EIO - Current task mm is not the same as the one
|
||||
* that created the enclave.
|
||||
* * NE_ERR_NO_CPUS_AVAIL_IN_POOL - No CPUs available in the NE CPU pool.
|
||||
* * NE_ERR_VCPU_ALREADY_USED - The provided vCPU is already used.
|
||||
* * NE_ERR_VCPU_NOT_IN_CPU_POOL - The provided vCPU is not available in the
|
||||
* NE CPU pool.
|
||||
* * NE_ERR_VCPU_INVALID_CPU_CORE - The core id of the provided vCPU is invalid
|
||||
* or out of range.
|
||||
* * NE_ERR_NOT_IN_INIT_STATE - The enclave is not in init state
|
||||
* (init = before being started).
|
||||
* * NE_ERR_INVALID_VCPU - The provided vCPU is not in the available
|
||||
* CPUs range.
|
||||
* * Error codes from the NE PCI device request.
|
||||
*/
|
||||
#define NE_ADD_VCPU _IOWR(0xAE, 0x21, uint32_t)
|
||||
|
||||
/**
|
||||
* NE_GET_IMAGE_LOAD_INFO - The command is used to get information needed for
|
||||
* in-memory enclave image loading e.g. offset in
|
||||
* enclave memory to start placing the enclave image.
|
||||
* The image load info is an input / output parameter.
|
||||
* It includes info provided by the caller - flags -
|
||||
* and returns the offset in enclave memory where to
|
||||
* start placing the enclave image.
|
||||
* The ioctl can be invoked on the enclave fd, before
|
||||
* an enclave is started.
|
||||
*
|
||||
* Context: Process context.
|
||||
* Return:
|
||||
* * 0 - Logic successfully completed.
|
||||
* * -1 - There was a failure in the ioctl logic.
|
||||
* On failure, errno is set to:
|
||||
* * EFAULT - copy_from_user() / copy_to_user() failure.
|
||||
* * NE_ERR_NOT_IN_INIT_STATE - The enclave is not in init state (init =
|
||||
* before being started).
|
||||
* * NE_ERR_INVALID_FLAG_VALUE - The value of the provided flag is invalid.
|
||||
*/
|
||||
#define NE_GET_IMAGE_LOAD_INFO _IOWR(0xAE, 0x22, struct ne_image_load_info)
|
||||
|
||||
/**
|
||||
* NE_SET_USER_MEMORY_REGION - The command is used to set a memory region for an
|
||||
* enclave, given the allocated memory from the
|
||||
* userspace. Enclave memory needs to be from the
|
||||
* same NUMA node as the enclave CPUs.
|
||||
* The user memory region is an input parameter. It
|
||||
* includes info provided by the caller - flags,
|
||||
* memory size and userspace address.
|
||||
* The ioctl can be invoked on the enclave fd,
|
||||
* before an enclave is started.
|
||||
*
|
||||
* Context: Process context.
|
||||
* Return:
|
||||
* * 0 - Logic successfully completed.
|
||||
* * -1 - There was a failure in the ioctl logic.
|
||||
* On failure, errno is set to:
|
||||
* * EFAULT - copy_from_user() failure.
|
||||
* * EINVAL - Invalid physical memory region(s) e.g.
|
||||
* unaligned address.
|
||||
* * EIO - Current task mm is not the same as
|
||||
* the one that created the enclave.
|
||||
* * ENOMEM - Memory allocation failure for internal
|
||||
* bookkeeping variables.
|
||||
* * NE_ERR_NOT_IN_INIT_STATE - The enclave is not in init state
|
||||
* (init = before being started).
|
||||
* * NE_ERR_INVALID_MEM_REGION_SIZE - The memory size of the region is not
|
||||
* multiple of 2 MiB.
|
||||
* * NE_ERR_INVALID_MEM_REGION_ADDR - Invalid user space address given.
|
||||
* * NE_ERR_UNALIGNED_MEM_REGION_ADDR - Unaligned user space address given.
|
||||
* * NE_ERR_MEM_REGION_ALREADY_USED - The memory region is already used.
|
||||
* * NE_ERR_MEM_NOT_HUGE_PAGE - The memory region is not backed by
|
||||
* huge pages.
|
||||
* * NE_ERR_MEM_DIFFERENT_NUMA_NODE - The memory region is not from the same
|
||||
* NUMA node as the CPUs.
|
||||
* * NE_ERR_MEM_MAX_REGIONS - The number of memory regions set for
|
||||
* the enclave reached maximum.
|
||||
* * NE_ERR_INVALID_PAGE_SIZE - The memory region is not backed by
|
||||
* pages multiple of 2 MiB.
|
||||
* * NE_ERR_INVALID_FLAG_VALUE - The value of the provided flag is invalid.
|
||||
* * Error codes from get_user_pages().
|
||||
* * Error codes from the NE PCI device request.
|
||||
*/
|
||||
#define NE_SET_USER_MEMORY_REGION _IOW(0xAE, 0x23, struct ne_user_memory_region)
|
||||
|
||||
/**
|
||||
* NE_START_ENCLAVE - The command is used to trigger enclave start after the
|
||||
* enclave resources, such as memory and CPU, have been set.
|
||||
* The enclave start info is an input / output parameter. It
|
||||
* includes info provided by the caller - enclave cid and
|
||||
* flags - and returns the cid (if input cid is 0).
|
||||
* The ioctl can be invoked on the enclave fd, after an
|
||||
* enclave slot is created and resources, such as memory and
|
||||
* vCPUs are set for an enclave.
|
||||
*
|
||||
* Context: Process context.
|
||||
* Return:
|
||||
* * 0 - Logic successfully completed.
|
||||
* * -1 - There was a failure in the ioctl logic.
|
||||
* On failure, errno is set to:
|
||||
* * EFAULT - copy_from_user() / copy_to_user() failure.
|
||||
* * NE_ERR_NOT_IN_INIT_STATE - The enclave is not in init state
|
||||
* (init = before being started).
|
||||
* * NE_ERR_NO_MEM_REGIONS_ADDED - No memory regions are set.
|
||||
* * NE_ERR_NO_VCPUS_ADDED - No vCPUs are set.
|
||||
* * NE_ERR_FULL_CORES_NOT_USED - Full core(s) not set for the enclave.
|
||||
* * NE_ERR_ENCLAVE_MEM_MIN_SIZE - Enclave memory is less than minimum
|
||||
* memory size (64 MiB).
|
||||
* * NE_ERR_INVALID_FLAG_VALUE - The value of the provided flag is invalid.
|
||||
* * NE_ERR_INVALID_ENCLAVE_CID - The provided enclave CID is invalid.
|
||||
* * Error codes from the NE PCI device request.
|
||||
*/
|
||||
#define NE_START_ENCLAVE _IOWR(0xAE, 0x24, struct ne_enclave_start_info)
|
||||
|
||||
/**
|
||||
* DOC: NE specific error codes
|
||||
*/
|
||||
|
||||
/**
|
||||
* NE_ERR_VCPU_ALREADY_USED - The provided vCPU is already used.
|
||||
*/
|
||||
#define NE_ERR_VCPU_ALREADY_USED (256)
|
||||
/**
|
||||
* NE_ERR_VCPU_NOT_IN_CPU_POOL - The provided vCPU is not available in the
|
||||
* NE CPU pool.
|
||||
*/
|
||||
#define NE_ERR_VCPU_NOT_IN_CPU_POOL (257)
|
||||
/**
|
||||
* NE_ERR_VCPU_INVALID_CPU_CORE - The core id of the provided vCPU is invalid
|
||||
* or out of range of the NE CPU pool.
|
||||
*/
|
||||
#define NE_ERR_VCPU_INVALID_CPU_CORE (258)
|
||||
/**
|
||||
* NE_ERR_INVALID_MEM_REGION_SIZE - The user space memory region size is not
|
||||
* multiple of 2 MiB.
|
||||
*/
|
||||
#define NE_ERR_INVALID_MEM_REGION_SIZE (259)
|
||||
/**
|
||||
* NE_ERR_INVALID_MEM_REGION_ADDR - The user space memory region address range
|
||||
* is invalid.
|
||||
*/
|
||||
#define NE_ERR_INVALID_MEM_REGION_ADDR (260)
|
||||
/**
|
||||
* NE_ERR_UNALIGNED_MEM_REGION_ADDR - The user space memory region address is
|
||||
* not aligned.
|
||||
*/
|
||||
#define NE_ERR_UNALIGNED_MEM_REGION_ADDR (261)
|
||||
/**
|
||||
* NE_ERR_MEM_REGION_ALREADY_USED - The user space memory region is already used.
|
||||
*/
|
||||
#define NE_ERR_MEM_REGION_ALREADY_USED (262)
|
||||
/**
|
||||
* NE_ERR_MEM_NOT_HUGE_PAGE - The user space memory region is not backed by
|
||||
* contiguous physical huge page(s).
|
||||
*/
|
||||
#define NE_ERR_MEM_NOT_HUGE_PAGE (263)
|
||||
/**
|
||||
* NE_ERR_MEM_DIFFERENT_NUMA_NODE - The user space memory region is backed by
|
||||
* pages from different NUMA nodes than the CPUs.
|
||||
*/
|
||||
#define NE_ERR_MEM_DIFFERENT_NUMA_NODE (264)
|
||||
/**
|
||||
* NE_ERR_MEM_MAX_REGIONS - The supported max memory regions per enclaves has
|
||||
* been reached.
|
||||
*/
|
||||
#define NE_ERR_MEM_MAX_REGIONS (265)
|
||||
/**
|
||||
* NE_ERR_NO_MEM_REGIONS_ADDED - The command to start an enclave is triggered
|
||||
* and no memory regions are added.
|
||||
*/
|
||||
#define NE_ERR_NO_MEM_REGIONS_ADDED (266)
|
||||
/**
|
||||
* NE_ERR_NO_VCPUS_ADDED - The command to start an enclave is triggered and no
|
||||
* vCPUs are added.
|
||||
*/
|
||||
#define NE_ERR_NO_VCPUS_ADDED (267)
|
||||
/**
|
||||
* NE_ERR_ENCLAVE_MEM_MIN_SIZE - The enclave memory size is lower than the
|
||||
* minimum supported.
|
||||
*/
|
||||
#define NE_ERR_ENCLAVE_MEM_MIN_SIZE (268)
|
||||
/**
|
||||
* NE_ERR_FULL_CORES_NOT_USED - The command to start an enclave is triggered and
|
||||
* full CPU cores are not set.
|
||||
*/
|
||||
#define NE_ERR_FULL_CORES_NOT_USED (269)
|
||||
/**
|
||||
* NE_ERR_NOT_IN_INIT_STATE - The enclave is not in init state when setting
|
||||
* resources or triggering start.
|
||||
*/
|
||||
#define NE_ERR_NOT_IN_INIT_STATE (270)
|
||||
/**
|
||||
* NE_ERR_INVALID_VCPU - The provided vCPU is out of range of the available CPUs.
|
||||
*/
|
||||
#define NE_ERR_INVALID_VCPU (271)
|
||||
/**
|
||||
* NE_ERR_NO_CPUS_AVAIL_IN_POOL - The command to create an enclave is triggered
|
||||
* and no CPUs are available in the pool.
|
||||
*/
|
||||
#define NE_ERR_NO_CPUS_AVAIL_IN_POOL (272)
|
||||
/**
|
||||
* NE_ERR_INVALID_PAGE_SIZE - The user space memory region is not backed by pages
|
||||
* multiple of 2 MiB.
|
||||
*/
|
||||
#define NE_ERR_INVALID_PAGE_SIZE (273)
|
||||
/**
|
||||
* NE_ERR_INVALID_FLAG_VALUE - The provided flag value is invalid.
|
||||
*/
|
||||
#define NE_ERR_INVALID_FLAG_VALUE (274)
|
||||
/**
|
||||
* NE_ERR_INVALID_ENCLAVE_CID - The provided enclave CID is invalid, either
|
||||
* being a well-known value or the CID of the
|
||||
* parent / primary VM.
|
||||
*/
|
||||
#define NE_ERR_INVALID_ENCLAVE_CID (275)
|
||||
|
||||
/**
|
||||
* DOC: Image load info flags
|
||||
*/
|
||||
|
||||
/**
|
||||
* NE_EIF_IMAGE - Enclave Image Format (EIF)
|
||||
*/
|
||||
#define NE_EIF_IMAGE (0x01)
|
||||
|
||||
#define NE_IMAGE_LOAD_MAX_FLAG_VAL (0x02)
|
||||
|
||||
/**
|
||||
* struct ne_image_load_info - Info necessary for in-memory enclave image
|
||||
* loading (in / out).
|
||||
* @flags: Flags to determine the enclave image type
|
||||
* (e.g. Enclave Image Format - EIF) (in).
|
||||
* @memory_offset: Offset in enclave memory where to start placing the
|
||||
* enclave image (out).
|
||||
*/
|
||||
struct ne_image_load_info {
|
||||
uint64_t flags;
|
||||
uint64_t memory_offset;
|
||||
};
|
||||
|
||||
/**
|
||||
* DOC: User memory region flags
|
||||
*/
|
||||
|
||||
/**
|
||||
* NE_DEFAULT_MEMORY_REGION - Memory region for enclave general usage.
|
||||
*/
|
||||
#define NE_DEFAULT_MEMORY_REGION (0x00)
|
||||
|
||||
#define NE_MEMORY_REGION_MAX_FLAG_VAL (0x01)
|
||||
|
||||
/**
|
||||
* struct ne_user_memory_region - Memory region to be set for an enclave (in).
|
||||
* @flags: Flags to determine the usage for the memory region (in).
|
||||
* @memory_size: The size, in bytes, of the memory region to be set for
|
||||
* an enclave (in).
|
||||
* @userspace_addr: The start address of the userspace allocated memory of
|
||||
* the memory region to set for an enclave (in).
|
||||
*/
|
||||
struct ne_user_memory_region {
|
||||
uint64_t flags;
|
||||
uint64_t memory_size;
|
||||
uint64_t userspace_addr;
|
||||
};
|
||||
|
||||
/**
|
||||
* DOC: Enclave start info flags
|
||||
*/
|
||||
|
||||
/**
|
||||
* NE_ENCLAVE_PRODUCTION_MODE - Start enclave in production mode.
|
||||
*/
|
||||
#define NE_ENCLAVE_PRODUCTION_MODE (0x00)
|
||||
/**
|
||||
* NE_ENCLAVE_DEBUG_MODE - Start enclave in debug mode.
|
||||
*/
|
||||
#define NE_ENCLAVE_DEBUG_MODE (0x01)
|
||||
|
||||
#define NE_ENCLAVE_START_MAX_FLAG_VAL (0x02)
|
||||
|
||||
/**
|
||||
* struct ne_enclave_start_info - Setup info necessary for enclave start (in / out).
|
||||
* @flags: Flags for the enclave to start with (e.g. debug mode) (in).
|
||||
* @enclave_cid: Context ID (CID) for the enclave vsock device. If 0 as
|
||||
* input, the CID is autogenerated by the hypervisor and
|
||||
* returned back as output by the driver (in / out).
|
||||
*/
|
||||
struct ne_enclave_start_info {
|
||||
uint64_t flags;
|
||||
uint64_t enclave_cid;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_NITRO_ENCLAVES_H_ */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,97 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
#ifndef _LINUX_FW_CFG_H
|
||||
#define _LINUX_FW_CFG_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
#define FW_CFG_ACPI_DEVICE_ID "QEMU0002"
|
||||
|
||||
/* selector key values for "well-known" fw_cfg entries */
|
||||
#define FW_CFG_SIGNATURE 0x00
|
||||
#define FW_CFG_ID 0x01
|
||||
#define FW_CFG_UUID 0x02
|
||||
#define FW_CFG_RAM_SIZE 0x03
|
||||
#define FW_CFG_NOGRAPHIC 0x04
|
||||
#define FW_CFG_NB_CPUS 0x05
|
||||
#define FW_CFG_MACHINE_ID 0x06
|
||||
#define FW_CFG_KERNEL_ADDR 0x07
|
||||
#define FW_CFG_KERNEL_SIZE 0x08
|
||||
#define FW_CFG_KERNEL_CMDLINE 0x09
|
||||
#define FW_CFG_INITRD_ADDR 0x0a
|
||||
#define FW_CFG_INITRD_SIZE 0x0b
|
||||
#define FW_CFG_BOOT_DEVICE 0x0c
|
||||
#define FW_CFG_NUMA 0x0d
|
||||
#define FW_CFG_BOOT_MENU 0x0e
|
||||
#define FW_CFG_MAX_CPUS 0x0f
|
||||
#define FW_CFG_KERNEL_ENTRY 0x10
|
||||
#define FW_CFG_KERNEL_DATA 0x11
|
||||
#define FW_CFG_INITRD_DATA 0x12
|
||||
#define FW_CFG_CMDLINE_ADDR 0x13
|
||||
#define FW_CFG_CMDLINE_SIZE 0x14
|
||||
#define FW_CFG_CMDLINE_DATA 0x15
|
||||
#define FW_CFG_SETUP_ADDR 0x16
|
||||
#define FW_CFG_SETUP_SIZE 0x17
|
||||
#define FW_CFG_SETUP_DATA 0x18
|
||||
#define FW_CFG_FILE_DIR 0x19
|
||||
|
||||
#define FW_CFG_FILE_FIRST 0x20
|
||||
#define FW_CFG_FILE_SLOTS_MIN 0x10
|
||||
|
||||
#define FW_CFG_WRITE_CHANNEL 0x4000
|
||||
#define FW_CFG_ARCH_LOCAL 0x8000
|
||||
#define FW_CFG_ENTRY_MASK (~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL))
|
||||
|
||||
#define FW_CFG_INVALID 0xffff
|
||||
|
||||
/* width in bytes of fw_cfg control register */
|
||||
#define FW_CFG_CTL_SIZE 0x02
|
||||
|
||||
/* fw_cfg "file name" is up to 56 characters (including terminating nul) */
|
||||
#define FW_CFG_MAX_FILE_PATH 56
|
||||
|
||||
/* size in bytes of fw_cfg signature */
|
||||
#define FW_CFG_SIG_SIZE 4
|
||||
|
||||
/* FW_CFG_ID bits */
|
||||
#define FW_CFG_VERSION 0x01
|
||||
#define FW_CFG_VERSION_DMA 0x02
|
||||
|
||||
/* fw_cfg file directory entry type */
|
||||
struct fw_cfg_file {
|
||||
uint32_t size;
|
||||
uint16_t select;
|
||||
uint16_t reserved;
|
||||
char name[FW_CFG_MAX_FILE_PATH];
|
||||
};
|
||||
|
||||
/* FW_CFG_DMA_CONTROL bits */
|
||||
#define FW_CFG_DMA_CTL_ERROR 0x01
|
||||
#define FW_CFG_DMA_CTL_READ 0x02
|
||||
#define FW_CFG_DMA_CTL_SKIP 0x04
|
||||
#define FW_CFG_DMA_CTL_SELECT 0x08
|
||||
#define FW_CFG_DMA_CTL_WRITE 0x10
|
||||
|
||||
#define FW_CFG_DMA_SIGNATURE 0x51454d5520434647ULL /* "QEMU CFG" */
|
||||
|
||||
/* Control as first field allows for different structures selected by this
|
||||
* field, which might be useful in the future
|
||||
*/
|
||||
struct fw_cfg_dma_access {
|
||||
uint32_t control;
|
||||
uint32_t length;
|
||||
uint64_t address;
|
||||
};
|
||||
|
||||
#define FW_CFG_VMCOREINFO_FILENAME "etc/vmcoreinfo"
|
||||
|
||||
#define FW_CFG_VMCOREINFO_FORMAT_NONE 0x0
|
||||
#define FW_CFG_VMCOREINFO_FORMAT_ELF 0x1
|
||||
|
||||
struct fw_cfg_vmcoreinfo {
|
||||
uint16_t host_format;
|
||||
uint16_t guest_format;
|
||||
uint32_t size;
|
||||
uint64_t paddr;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
#ifndef _LINUX_SYSINFO_H
|
||||
#define _LINUX_SYSINFO_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
#define SI_LOAD_SHIFT 16
|
||||
struct sysinfo {
|
||||
long uptime; /* Seconds since boot */
|
||||
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
unsigned long totalram; /* Total usable main memory size */
|
||||
unsigned long freeram; /* Available memory size */
|
||||
unsigned long sharedram; /* Amount of shared memory */
|
||||
unsigned long bufferram; /* Memory used by buffers */
|
||||
unsigned long totalswap; /* Total swap space size */
|
||||
unsigned long freeswap; /* swap space still available */
|
||||
uint16_t procs; /* Number of current processes */
|
||||
uint16_t pad; /* Explicit padding for m68k */
|
||||
unsigned long totalhigh; /* Total high memory size */
|
||||
unsigned long freehigh; /* Available high memory size */
|
||||
uint32_t mem_unit; /* Memory unit size in bytes */
|
||||
char _f[20-2*sizeof(unsigned long)-sizeof(uint32_t)]; /* Padding: libc5 uses this.. */
|
||||
};
|
||||
|
||||
#endif /* _LINUX_SYSINFO_H */
|
||||
@@ -0,0 +1,8 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
#ifndef _LINUX_TYPELIMITS_H
|
||||
#define _LINUX_TYPELIMITS_H
|
||||
|
||||
#define __KERNEL_INT_MAX ((int)(~0U >> 1))
|
||||
#define __KERNEL_INT_MIN (-__KERNEL_INT_MAX - 1)
|
||||
|
||||
#endif /* _LINUX_TYPELIMITS_H */
|
||||
@@ -0,0 +1,3 @@
|
||||
/* For QEMU all types are already defined via osdep.h, so this
|
||||
* header does not need to do anything.
|
||||
*/
|
||||
@@ -0,0 +1,32 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
#ifndef _LINUX_UDMABUF_H
|
||||
#define _LINUX_UDMABUF_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
#define UDMABUF_FLAGS_CLOEXEC 0x01
|
||||
|
||||
struct udmabuf_create {
|
||||
uint32_t memfd;
|
||||
uint32_t flags;
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
struct udmabuf_create_item {
|
||||
uint32_t memfd;
|
||||
uint32_t __pad;
|
||||
uint64_t offset;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
struct udmabuf_create_list {
|
||||
uint32_t flags;
|
||||
uint32_t count;
|
||||
struct udmabuf_create_item list[];
|
||||
};
|
||||
|
||||
#define UDMABUF_CREATE _IOW('u', 0x42, struct udmabuf_create)
|
||||
#define UDMABUF_CREATE_LIST _IOW('u', 0x43, struct udmabuf_create_list)
|
||||
|
||||
#endif /* _LINUX_UDMABUF_H */
|
||||
@@ -0,0 +1,201 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
#ifndef _LINUX_VHOST_TYPES_H
|
||||
#define _LINUX_VHOST_TYPES_H
|
||||
/* Userspace interface for in-kernel virtio accelerators. */
|
||||
|
||||
/* vhost is used to reduce the number of system calls involved in virtio.
|
||||
*
|
||||
* Existing virtio net code is used in the guest without modification.
|
||||
*
|
||||
* This header includes interface used by userspace hypervisor for
|
||||
* device configuration.
|
||||
*/
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
#include "standard-headers/linux/virtio_ring.h"
|
||||
|
||||
struct vhost_vring_state {
|
||||
unsigned int index;
|
||||
unsigned int num;
|
||||
};
|
||||
|
||||
struct vhost_vring_file {
|
||||
unsigned int index;
|
||||
int fd; /* Pass -1 to unbind from file. */
|
||||
|
||||
};
|
||||
|
||||
struct vhost_vring_addr {
|
||||
unsigned int index;
|
||||
/* Option flags. */
|
||||
unsigned int flags;
|
||||
/* Flag values: */
|
||||
/* Whether log address is valid. If set enables logging. */
|
||||
#define VHOST_VRING_F_LOG 0
|
||||
|
||||
/* Start of array of descriptors (virtually contiguous) */
|
||||
uint64_t desc_user_addr;
|
||||
/* Used structure address. Must be 32 bit aligned */
|
||||
uint64_t used_user_addr;
|
||||
/* Available structure address. Must be 16 bit aligned */
|
||||
uint64_t avail_user_addr;
|
||||
/* Logging support. */
|
||||
/* Log writes to used structure, at offset calculated from specified
|
||||
* address. Address must be 32 bit aligned. */
|
||||
uint64_t log_guest_addr;
|
||||
};
|
||||
|
||||
struct vhost_worker_state {
|
||||
/*
|
||||
* For VHOST_NEW_WORKER the kernel will return the new vhost_worker id.
|
||||
* For VHOST_FREE_WORKER this must be set to the id of the vhost_worker
|
||||
* to free.
|
||||
*/
|
||||
unsigned int worker_id;
|
||||
};
|
||||
|
||||
struct vhost_vring_worker {
|
||||
/* vring index */
|
||||
unsigned int index;
|
||||
/* The id of the vhost_worker returned from VHOST_NEW_WORKER */
|
||||
unsigned int worker_id;
|
||||
};
|
||||
|
||||
/* no alignment requirement */
|
||||
struct vhost_iotlb_msg {
|
||||
uint64_t iova;
|
||||
uint64_t size;
|
||||
uint64_t uaddr;
|
||||
#define VHOST_ACCESS_RO 0x1
|
||||
#define VHOST_ACCESS_WO 0x2
|
||||
#define VHOST_ACCESS_RW 0x3
|
||||
uint8_t perm;
|
||||
#define VHOST_IOTLB_MISS 1
|
||||
#define VHOST_IOTLB_UPDATE 2
|
||||
#define VHOST_IOTLB_INVALIDATE 3
|
||||
#define VHOST_IOTLB_ACCESS_FAIL 4
|
||||
/*
|
||||
* VHOST_IOTLB_BATCH_BEGIN and VHOST_IOTLB_BATCH_END allow modifying
|
||||
* multiple mappings in one go: beginning with
|
||||
* VHOST_IOTLB_BATCH_BEGIN, followed by any number of
|
||||
* VHOST_IOTLB_UPDATE messages, and ending with VHOST_IOTLB_BATCH_END.
|
||||
* When one of these two values is used as the message type, the rest
|
||||
* of the fields in the message are ignored. There's no guarantee that
|
||||
* these changes take place automatically in the device.
|
||||
*/
|
||||
#define VHOST_IOTLB_BATCH_BEGIN 5
|
||||
#define VHOST_IOTLB_BATCH_END 6
|
||||
uint8_t type;
|
||||
};
|
||||
|
||||
#define VHOST_IOTLB_MSG 0x1
|
||||
#define VHOST_IOTLB_MSG_V2 0x2
|
||||
|
||||
struct vhost_msg {
|
||||
int type;
|
||||
union {
|
||||
struct vhost_iotlb_msg iotlb;
|
||||
uint8_t padding[64];
|
||||
};
|
||||
};
|
||||
|
||||
struct vhost_msg_v2 {
|
||||
uint32_t type;
|
||||
uint32_t asid;
|
||||
union {
|
||||
struct vhost_iotlb_msg iotlb;
|
||||
uint8_t padding[64];
|
||||
};
|
||||
};
|
||||
|
||||
struct vhost_features_array {
|
||||
uint64_t count; /* number of entries present in features array */
|
||||
uint64_t features[] ;
|
||||
};
|
||||
|
||||
struct vhost_memory_region {
|
||||
uint64_t guest_phys_addr;
|
||||
uint64_t memory_size; /* bytes */
|
||||
uint64_t userspace_addr;
|
||||
uint64_t flags_padding; /* No flags are currently specified. */
|
||||
};
|
||||
|
||||
/* All region addresses and sizes must be 4K aligned. */
|
||||
#define VHOST_PAGE_SIZE 0x1000
|
||||
|
||||
struct vhost_memory {
|
||||
uint32_t nregions;
|
||||
uint32_t padding;
|
||||
struct vhost_memory_region regions[];
|
||||
};
|
||||
|
||||
/* VHOST_SCSI specific definitions */
|
||||
|
||||
/*
|
||||
* Used by QEMU userspace to ensure a consistent vhost-scsi ABI.
|
||||
*
|
||||
* ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate +
|
||||
* RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl usage
|
||||
* ABI Rev 1: January 2013. Ignore vhost_tpgt field in struct vhost_scsi_target.
|
||||
* All the targets under vhost_wwpn can be seen and used by guset.
|
||||
*/
|
||||
|
||||
#define VHOST_SCSI_ABI_VERSION 1
|
||||
|
||||
struct vhost_scsi_target {
|
||||
int abi_version;
|
||||
char vhost_wwpn[224]; /* TRANSPORT_IQN_LEN */
|
||||
unsigned short vhost_tpgt;
|
||||
unsigned short reserved;
|
||||
};
|
||||
|
||||
/* VHOST_VDPA specific definitions */
|
||||
|
||||
struct vhost_vdpa_config {
|
||||
uint32_t off;
|
||||
uint32_t len;
|
||||
uint8_t buf[];
|
||||
};
|
||||
|
||||
/* vhost vdpa IOVA range
|
||||
* @first: First address that can be mapped by vhost-vDPA
|
||||
* @last: Last address that can be mapped by vhost-vDPA
|
||||
*/
|
||||
struct vhost_vdpa_iova_range {
|
||||
uint64_t first;
|
||||
uint64_t last;
|
||||
};
|
||||
|
||||
/* Feature bits */
|
||||
/* Log all write descriptors. Can be changed while device is active. */
|
||||
#define VHOST_F_LOG_ALL 26
|
||||
/* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */
|
||||
#define VHOST_NET_F_VIRTIO_NET_HDR 27
|
||||
|
||||
/* Use message type V2 */
|
||||
#define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1
|
||||
/* IOTLB can accept batching hints */
|
||||
#define VHOST_BACKEND_F_IOTLB_BATCH 0x2
|
||||
/* IOTLB can accept address space identifier through V2 type of IOTLB
|
||||
* message
|
||||
*/
|
||||
#define VHOST_BACKEND_F_IOTLB_ASID 0x3
|
||||
/* Device can be suspended */
|
||||
#define VHOST_BACKEND_F_SUSPEND 0x4
|
||||
/* Device can be resumed */
|
||||
#define VHOST_BACKEND_F_RESUME 0x5
|
||||
/* Device supports the driver enabling virtqueues both before and after
|
||||
* DRIVER_OK
|
||||
*/
|
||||
#define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK 0x6
|
||||
/* Device may expose the virtqueue's descriptor area, driver area and
|
||||
* device area to a different group for ASID binding than where its
|
||||
* buffers may reside. Requires VHOST_BACKEND_F_IOTLB_ASID.
|
||||
*/
|
||||
#define VHOST_BACKEND_F_DESC_ASID 0x7
|
||||
/* IOTLB don't flush memory mapping across device reset */
|
||||
#define VHOST_BACKEND_F_IOTLB_PERSIST 0x8
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef _LINUX_VIRTIO_9P_H
|
||||
#define _LINUX_VIRTIO_9P_H
|
||||
/* This header is BSD licensed so anyone can use the definitions to implement
|
||||
* compatible drivers/servers.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE. */
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
|
||||
/* The feature bitmap for virtio 9P */
|
||||
|
||||
/* The mount point is specified in a config variable */
|
||||
#define VIRTIO_9P_MOUNT_TAG 0
|
||||
|
||||
struct virtio_9p_config {
|
||||
/* length of the tag name */
|
||||
__virtio16 tag_len;
|
||||
/* non-NULL terminated tag name */
|
||||
uint8_t tag[];
|
||||
} QEMU_PACKED;
|
||||
|
||||
#endif /* _LINUX_VIRTIO_9P_H */
|
||||
@@ -0,0 +1,131 @@
|
||||
#ifndef _LINUX_VIRTIO_BALLOON_H
|
||||
#define _LINUX_VIRTIO_BALLOON_H
|
||||
/* This header is BSD licensed so anyone can use the definitions to implement
|
||||
* compatible drivers/servers.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE. */
|
||||
#include "standard-headers/linux/types.h"
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
|
||||
/* The feature bitmap for virtio balloon */
|
||||
#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */
|
||||
#define VIRTIO_BALLOON_F_STATS_VQ 1 /* Memory Stats virtqueue */
|
||||
#define VIRTIO_BALLOON_F_DEFLATE_ON_OOM 2 /* Deflate balloon on OOM */
|
||||
#define VIRTIO_BALLOON_F_FREE_PAGE_HINT 3 /* VQ to report free pages */
|
||||
#define VIRTIO_BALLOON_F_PAGE_POISON 4 /* Guest is using page poisoning */
|
||||
#define VIRTIO_BALLOON_F_REPORTING 5 /* Page reporting virtqueue */
|
||||
|
||||
/* Size of a PFN in the balloon interface. */
|
||||
#define VIRTIO_BALLOON_PFN_SHIFT 12
|
||||
|
||||
#define VIRTIO_BALLOON_CMD_ID_STOP 0
|
||||
#define VIRTIO_BALLOON_CMD_ID_DONE 1
|
||||
struct virtio_balloon_config {
|
||||
/* Number of pages host wants Guest to give up. */
|
||||
uint32_t num_pages;
|
||||
/* Number of pages we've actually got in balloon. */
|
||||
uint32_t actual;
|
||||
/*
|
||||
* Free page hint command id, readonly by guest.
|
||||
* Was previously named free_page_report_cmd_id so we
|
||||
* need to carry that name for legacy support.
|
||||
*/
|
||||
union {
|
||||
uint32_t free_page_hint_cmd_id;
|
||||
uint32_t free_page_report_cmd_id; /* deprecated */
|
||||
};
|
||||
/* Stores PAGE_POISON if page poisoning is in use */
|
||||
uint32_t poison_val;
|
||||
};
|
||||
|
||||
#define VIRTIO_BALLOON_S_SWAP_IN 0 /* Amount of memory swapped in */
|
||||
#define VIRTIO_BALLOON_S_SWAP_OUT 1 /* Amount of memory swapped out */
|
||||
#define VIRTIO_BALLOON_S_MAJFLT 2 /* Number of major faults */
|
||||
#define VIRTIO_BALLOON_S_MINFLT 3 /* Number of minor faults */
|
||||
#define VIRTIO_BALLOON_S_MEMFREE 4 /* Total amount of free memory */
|
||||
#define VIRTIO_BALLOON_S_MEMTOT 5 /* Total amount of memory */
|
||||
#define VIRTIO_BALLOON_S_AVAIL 6 /* Available memory as in /proc */
|
||||
#define VIRTIO_BALLOON_S_CACHES 7 /* Disk caches */
|
||||
#define VIRTIO_BALLOON_S_HTLB_PGALLOC 8 /* Hugetlb page allocations */
|
||||
#define VIRTIO_BALLOON_S_HTLB_PGFAIL 9 /* Hugetlb page allocation failures */
|
||||
#define VIRTIO_BALLOON_S_OOM_KILL 10 /* OOM killer invocations */
|
||||
#define VIRTIO_BALLOON_S_ALLOC_STALL 11 /* Stall count of memory allocatoin */
|
||||
#define VIRTIO_BALLOON_S_ASYNC_SCAN 12 /* Amount of memory scanned asynchronously */
|
||||
#define VIRTIO_BALLOON_S_DIRECT_SCAN 13 /* Amount of memory scanned directly */
|
||||
#define VIRTIO_BALLOON_S_ASYNC_RECLAIM 14 /* Amount of memory reclaimed asynchronously */
|
||||
#define VIRTIO_BALLOON_S_DIRECT_RECLAIM 15 /* Amount of memory reclaimed directly */
|
||||
#define VIRTIO_BALLOON_S_NR 16
|
||||
|
||||
#define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "swap-out", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "major-faults", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "minor-faults", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "free-memory", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "total-memory", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "available-memory", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "disk-caches", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-allocations", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "oom-kills", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "alloc-stalls", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "async-scans", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "direct-scans", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "async-reclaims", \
|
||||
VIRTIO_BALLOON_S_NAMES_prefix "direct-reclaims" \
|
||||
}
|
||||
|
||||
#define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("")
|
||||
|
||||
/*
|
||||
* Memory statistics structure.
|
||||
* Driver fills an array of these structures and passes to device.
|
||||
*
|
||||
* NOTE: fields are laid out in a way that would make compiler add padding
|
||||
* between and after fields, so we have to use compiler-specific attributes to
|
||||
* pack it, to disable this padding. This also often causes compiler to
|
||||
* generate suboptimal code.
|
||||
*
|
||||
* We maintain this statistics structure format for backwards compatibility,
|
||||
* but don't follow this example.
|
||||
*
|
||||
* If implementing a similar structure, do something like the below instead:
|
||||
* struct virtio_balloon_stat {
|
||||
* __virtio16 tag;
|
||||
* uint8_t reserved[6];
|
||||
* __virtio64 val;
|
||||
* };
|
||||
*
|
||||
* In other words, add explicit reserved fields to align field and
|
||||
* structure boundaries at field size, avoiding compiler padding
|
||||
* without the packed attribute.
|
||||
*/
|
||||
struct virtio_balloon_stat {
|
||||
__virtio16 tag;
|
||||
__virtio64 val;
|
||||
} QEMU_PACKED;
|
||||
|
||||
#endif /* _LINUX_VIRTIO_BALLOON_H */
|
||||
@@ -0,0 +1,325 @@
|
||||
#ifndef _LINUX_VIRTIO_BLK_H
|
||||
#define _LINUX_VIRTIO_BLK_H
|
||||
/* This header is BSD licensed so anyone can use the definitions to implement
|
||||
* compatible drivers/servers.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE. */
|
||||
#include "standard-headers/linux/types.h"
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
|
||||
/* Feature bits */
|
||||
#define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */
|
||||
#define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
|
||||
#define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */
|
||||
#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
|
||||
#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
|
||||
#define VIRTIO_BLK_F_TOPOLOGY 10 /* Topology information is available */
|
||||
#define VIRTIO_BLK_F_MQ 12 /* support more than one vq */
|
||||
#define VIRTIO_BLK_F_DISCARD 13 /* DISCARD is supported */
|
||||
#define VIRTIO_BLK_F_WRITE_ZEROES 14 /* WRITE ZEROES is supported */
|
||||
#define VIRTIO_BLK_F_SECURE_ERASE 16 /* Secure Erase is supported */
|
||||
#define VIRTIO_BLK_F_ZONED 17 /* Zoned block device */
|
||||
|
||||
/* Legacy feature bits */
|
||||
#ifndef VIRTIO_BLK_NO_LEGACY
|
||||
#define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */
|
||||
#define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */
|
||||
#define VIRTIO_BLK_F_FLUSH 9 /* Flush command supported */
|
||||
#define VIRTIO_BLK_F_CONFIG_WCE 11 /* Writeback mode available in config */
|
||||
/* Old (deprecated) name for VIRTIO_BLK_F_FLUSH. */
|
||||
#define VIRTIO_BLK_F_WCE VIRTIO_BLK_F_FLUSH
|
||||
#endif /* !VIRTIO_BLK_NO_LEGACY */
|
||||
|
||||
#define VIRTIO_BLK_ID_BYTES 20 /* ID string length */
|
||||
|
||||
struct virtio_blk_config {
|
||||
/* The capacity (in 512-byte sectors). */
|
||||
__virtio64 capacity;
|
||||
/* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
|
||||
__virtio32 size_max;
|
||||
/* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */
|
||||
__virtio32 seg_max;
|
||||
/* geometry of the device (if VIRTIO_BLK_F_GEOMETRY) */
|
||||
struct virtio_blk_geometry {
|
||||
__virtio16 cylinders;
|
||||
uint8_t heads;
|
||||
uint8_t sectors;
|
||||
} geometry;
|
||||
|
||||
/* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
|
||||
__virtio32 blk_size;
|
||||
|
||||
/* the next 4 entries are guarded by VIRTIO_BLK_F_TOPOLOGY */
|
||||
/* exponent for physical block per logical block. */
|
||||
uint8_t physical_block_exp;
|
||||
/* alignment offset in logical blocks. */
|
||||
uint8_t alignment_offset;
|
||||
/* minimum I/O size without performance penalty in logical blocks. */
|
||||
__virtio16 min_io_size;
|
||||
/* optimal sustained I/O size in logical blocks. */
|
||||
__virtio32 opt_io_size;
|
||||
|
||||
/* writeback mode (if VIRTIO_BLK_F_CONFIG_WCE) */
|
||||
uint8_t wce;
|
||||
uint8_t unused;
|
||||
|
||||
/* number of vqs, only available when VIRTIO_BLK_F_MQ is set */
|
||||
__virtio16 num_queues;
|
||||
|
||||
/* the next 3 entries are guarded by VIRTIO_BLK_F_DISCARD */
|
||||
/*
|
||||
* The maximum discard sectors (in 512-byte sectors) for
|
||||
* one segment.
|
||||
*/
|
||||
__virtio32 max_discard_sectors;
|
||||
/*
|
||||
* The maximum number of discard segments in a
|
||||
* discard command.
|
||||
*/
|
||||
__virtio32 max_discard_seg;
|
||||
/* Discard commands must be aligned to this number of sectors. */
|
||||
__virtio32 discard_sector_alignment;
|
||||
|
||||
/* the next 3 entries are guarded by VIRTIO_BLK_F_WRITE_ZEROES */
|
||||
/*
|
||||
* The maximum number of write zeroes sectors (in 512-byte sectors) in
|
||||
* one segment.
|
||||
*/
|
||||
__virtio32 max_write_zeroes_sectors;
|
||||
/*
|
||||
* The maximum number of segments in a write zeroes
|
||||
* command.
|
||||
*/
|
||||
__virtio32 max_write_zeroes_seg;
|
||||
/*
|
||||
* Set if a VIRTIO_BLK_T_WRITE_ZEROES request may result in the
|
||||
* deallocation of one or more of the sectors.
|
||||
*/
|
||||
uint8_t write_zeroes_may_unmap;
|
||||
|
||||
uint8_t unused1[3];
|
||||
|
||||
/* the next 3 entries are guarded by VIRTIO_BLK_F_SECURE_ERASE */
|
||||
/*
|
||||
* The maximum secure erase sectors (in 512-byte sectors) for
|
||||
* one segment.
|
||||
*/
|
||||
__virtio32 max_secure_erase_sectors;
|
||||
/*
|
||||
* The maximum number of secure erase segments in a
|
||||
* secure erase command.
|
||||
*/
|
||||
__virtio32 max_secure_erase_seg;
|
||||
/* Secure erase commands must be aligned to this number of sectors. */
|
||||
__virtio32 secure_erase_sector_alignment;
|
||||
|
||||
/* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */
|
||||
struct virtio_blk_zoned_characteristics {
|
||||
__virtio32 zone_sectors;
|
||||
__virtio32 max_open_zones;
|
||||
__virtio32 max_active_zones;
|
||||
__virtio32 max_append_sectors;
|
||||
__virtio32 write_granularity;
|
||||
uint8_t model;
|
||||
uint8_t unused2[3];
|
||||
} zoned;
|
||||
} QEMU_PACKED;
|
||||
|
||||
/*
|
||||
* Command types
|
||||
*
|
||||
* Usage is a bit tricky as some bits are used as flags and some are not.
|
||||
*
|
||||
* Rules:
|
||||
* VIRTIO_BLK_T_OUT may be combined with VIRTIO_BLK_T_SCSI_CMD or
|
||||
* VIRTIO_BLK_T_BARRIER. VIRTIO_BLK_T_FLUSH is a command of its own
|
||||
* and may not be combined with any of the other flags.
|
||||
*/
|
||||
|
||||
/* These two define direction. */
|
||||
#define VIRTIO_BLK_T_IN 0
|
||||
#define VIRTIO_BLK_T_OUT 1
|
||||
|
||||
#ifndef VIRTIO_BLK_NO_LEGACY
|
||||
/* This bit says it's a scsi command, not an actual read or write. */
|
||||
#define VIRTIO_BLK_T_SCSI_CMD 2
|
||||
#endif /* VIRTIO_BLK_NO_LEGACY */
|
||||
|
||||
/* Cache flush command */
|
||||
#define VIRTIO_BLK_T_FLUSH 4
|
||||
|
||||
/* Get device ID command */
|
||||
#define VIRTIO_BLK_T_GET_ID 8
|
||||
|
||||
/* Discard command */
|
||||
#define VIRTIO_BLK_T_DISCARD 11
|
||||
|
||||
/* Write zeroes command */
|
||||
#define VIRTIO_BLK_T_WRITE_ZEROES 13
|
||||
|
||||
/* Secure erase command */
|
||||
#define VIRTIO_BLK_T_SECURE_ERASE 14
|
||||
|
||||
/* Zone append command */
|
||||
#define VIRTIO_BLK_T_ZONE_APPEND 15
|
||||
|
||||
/* Report zones command */
|
||||
#define VIRTIO_BLK_T_ZONE_REPORT 16
|
||||
|
||||
/* Open zone command */
|
||||
#define VIRTIO_BLK_T_ZONE_OPEN 18
|
||||
|
||||
/* Close zone command */
|
||||
#define VIRTIO_BLK_T_ZONE_CLOSE 20
|
||||
|
||||
/* Finish zone command */
|
||||
#define VIRTIO_BLK_T_ZONE_FINISH 22
|
||||
|
||||
/* Reset zone command */
|
||||
#define VIRTIO_BLK_T_ZONE_RESET 24
|
||||
|
||||
/* Reset All zones command */
|
||||
#define VIRTIO_BLK_T_ZONE_RESET_ALL 26
|
||||
|
||||
#ifndef VIRTIO_BLK_NO_LEGACY
|
||||
/* Barrier before this op. */
|
||||
#define VIRTIO_BLK_T_BARRIER 0x80000000
|
||||
#endif /* !VIRTIO_BLK_NO_LEGACY */
|
||||
|
||||
/*
|
||||
* This comes first in the read scatter-gather list.
|
||||
* For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated,
|
||||
* this is the first element of the read scatter-gather list.
|
||||
*/
|
||||
struct virtio_blk_outhdr {
|
||||
/* VIRTIO_BLK_T* */
|
||||
__virtio32 type;
|
||||
/* io priority. */
|
||||
__virtio32 ioprio;
|
||||
/* Sector (ie. 512 byte offset) */
|
||||
__virtio64 sector;
|
||||
};
|
||||
|
||||
/*
|
||||
* Supported zoned device models.
|
||||
*/
|
||||
|
||||
/* Regular block device */
|
||||
#define VIRTIO_BLK_Z_NONE 0
|
||||
/* Host-managed zoned device */
|
||||
#define VIRTIO_BLK_Z_HM 1
|
||||
/* Host-aware zoned device */
|
||||
#define VIRTIO_BLK_Z_HA 2
|
||||
|
||||
/*
|
||||
* Zone descriptor. A part of VIRTIO_BLK_T_ZONE_REPORT command reply.
|
||||
*/
|
||||
struct virtio_blk_zone_descriptor {
|
||||
/* Zone capacity */
|
||||
__virtio64 z_cap;
|
||||
/* The starting sector of the zone */
|
||||
__virtio64 z_start;
|
||||
/* Zone write pointer position in sectors */
|
||||
__virtio64 z_wp;
|
||||
/* Zone type */
|
||||
uint8_t z_type;
|
||||
/* Zone state */
|
||||
uint8_t z_state;
|
||||
uint8_t reserved[38];
|
||||
};
|
||||
|
||||
struct virtio_blk_zone_report {
|
||||
__virtio64 nr_zones;
|
||||
uint8_t reserved[56];
|
||||
struct virtio_blk_zone_descriptor zones[];
|
||||
};
|
||||
|
||||
/*
|
||||
* Supported zone types.
|
||||
*/
|
||||
|
||||
/* Conventional zone */
|
||||
#define VIRTIO_BLK_ZT_CONV 1
|
||||
/* Sequential Write Required zone */
|
||||
#define VIRTIO_BLK_ZT_SWR 2
|
||||
/* Sequential Write Preferred zone */
|
||||
#define VIRTIO_BLK_ZT_SWP 3
|
||||
|
||||
/*
|
||||
* Zone states that are available for zones of all types.
|
||||
*/
|
||||
|
||||
/* Not a write pointer (conventional zones only) */
|
||||
#define VIRTIO_BLK_ZS_NOT_WP 0
|
||||
/* Empty */
|
||||
#define VIRTIO_BLK_ZS_EMPTY 1
|
||||
/* Implicitly Open */
|
||||
#define VIRTIO_BLK_ZS_IOPEN 2
|
||||
/* Explicitly Open */
|
||||
#define VIRTIO_BLK_ZS_EOPEN 3
|
||||
/* Closed */
|
||||
#define VIRTIO_BLK_ZS_CLOSED 4
|
||||
/* Read-Only */
|
||||
#define VIRTIO_BLK_ZS_RDONLY 13
|
||||
/* Full */
|
||||
#define VIRTIO_BLK_ZS_FULL 14
|
||||
/* Offline */
|
||||
#define VIRTIO_BLK_ZS_OFFLINE 15
|
||||
|
||||
/* Unmap this range (only valid for write zeroes command) */
|
||||
#define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP 0x00000001
|
||||
|
||||
/* Discard/write zeroes range for each request. */
|
||||
struct virtio_blk_discard_write_zeroes {
|
||||
/* discard/write zeroes start sector */
|
||||
uint64_t sector;
|
||||
/* number of discard/write zeroes sectors */
|
||||
uint32_t num_sectors;
|
||||
/* flags for this range */
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
#ifndef VIRTIO_BLK_NO_LEGACY
|
||||
struct virtio_scsi_inhdr {
|
||||
__virtio32 errors;
|
||||
__virtio32 data_len;
|
||||
__virtio32 sense_len;
|
||||
__virtio32 residual;
|
||||
};
|
||||
#endif /* !VIRTIO_BLK_NO_LEGACY */
|
||||
|
||||
/* And this is the final byte of the write scatter-gather list. */
|
||||
#define VIRTIO_BLK_S_OK 0
|
||||
#define VIRTIO_BLK_S_IOERR 1
|
||||
#define VIRTIO_BLK_S_UNSUPP 2
|
||||
|
||||
/* Error codes that are specific to zoned block devices */
|
||||
#define VIRTIO_BLK_S_ZONE_INVALID_CMD 3
|
||||
#define VIRTIO_BLK_S_ZONE_UNALIGNED_WP 4
|
||||
#define VIRTIO_BLK_S_ZONE_OPEN_RESOURCE 5
|
||||
#define VIRTIO_BLK_S_ZONE_ACTIVE_RESOURCE 6
|
||||
|
||||
#endif /* _LINUX_VIRTIO_BLK_H */
|
||||
@@ -0,0 +1,38 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#ifndef _LINUX_VIRTIO_BT_H
|
||||
#define _LINUX_VIRTIO_BT_H
|
||||
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
|
||||
/* Feature bits */
|
||||
#define VIRTIO_BT_F_VND_HCI 0 /* Indicates vendor command support */
|
||||
#define VIRTIO_BT_F_MSFT_EXT 1 /* Indicates MSFT vendor support */
|
||||
#define VIRTIO_BT_F_AOSP_EXT 2 /* Indicates AOSP vendor support */
|
||||
#define VIRTIO_BT_F_CONFIG_V2 3 /* Use second version configuration */
|
||||
|
||||
enum virtio_bt_config_type {
|
||||
VIRTIO_BT_CONFIG_TYPE_PRIMARY = 0,
|
||||
};
|
||||
|
||||
enum virtio_bt_config_vendor {
|
||||
VIRTIO_BT_CONFIG_VENDOR_NONE = 0,
|
||||
VIRTIO_BT_CONFIG_VENDOR_ZEPHYR = 1,
|
||||
VIRTIO_BT_CONFIG_VENDOR_INTEL = 2,
|
||||
VIRTIO_BT_CONFIG_VENDOR_REALTEK = 3,
|
||||
};
|
||||
|
||||
struct virtio_bt_config {
|
||||
uint8_t type;
|
||||
uint16_t vendor;
|
||||
uint16_t msft_opcode;
|
||||
} QEMU_PACKED;
|
||||
|
||||
struct virtio_bt_config_v2 {
|
||||
uint8_t type;
|
||||
uint8_t alignment;
|
||||
uint16_t vendor;
|
||||
uint16_t msft_opcode;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_VIRTIO_BT_H */
|
||||
@@ -0,0 +1,78 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/*
|
||||
* Copyright (C) 2021-2023 OpenSynergy GmbH
|
||||
* Copyright Red Hat, Inc. 2025
|
||||
*/
|
||||
#ifndef _LINUX_VIRTIO_VIRTIO_CAN_H
|
||||
#define _LINUX_VIRTIO_VIRTIO_CAN_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
|
||||
/* Feature bit numbers */
|
||||
#define VIRTIO_CAN_F_CAN_CLASSIC 0
|
||||
#define VIRTIO_CAN_F_CAN_FD 1
|
||||
#define VIRTIO_CAN_F_RTR_FRAMES 2
|
||||
#define VIRTIO_CAN_F_LATE_TX_ACK 3
|
||||
|
||||
/* CAN Result Types */
|
||||
#define VIRTIO_CAN_RESULT_OK 0
|
||||
#define VIRTIO_CAN_RESULT_NOT_OK 1
|
||||
|
||||
/* CAN flags to determine type of CAN Id */
|
||||
#define VIRTIO_CAN_FLAGS_EXTENDED 0x8000
|
||||
#define VIRTIO_CAN_FLAGS_FD 0x4000
|
||||
#define VIRTIO_CAN_FLAGS_RTR 0x2000
|
||||
|
||||
#define VIRTIO_CAN_MAX_DLEN 64 /* this is like CANFD_MAX_DLEN */
|
||||
|
||||
struct virtio_can_config {
|
||||
#define VIRTIO_CAN_S_CTRL_BUSOFF (1u << 0) /* Controller BusOff */
|
||||
/* CAN controller status */
|
||||
uint16_t status;
|
||||
};
|
||||
|
||||
/* TX queue message types */
|
||||
struct virtio_can_tx_out {
|
||||
#define VIRTIO_CAN_TX 0x0001
|
||||
uint16_t msg_type;
|
||||
uint16_t length; /* 0..8 CC, 0..64 CAN-FD, 0..2048 CAN-XL, 12 bits */
|
||||
uint8_t reserved_classic_dlc; /* If CAN classic length = 8 then DLC can be 8..15 */
|
||||
uint8_t padding;
|
||||
uint16_t reserved_xl_priority; /* May be needed for CAN XL priority */
|
||||
uint32_t flags;
|
||||
uint32_t can_id;
|
||||
uint8_t sdu[] __counted_by_le(length);
|
||||
};
|
||||
|
||||
struct virtio_can_tx_in {
|
||||
uint8_t result;
|
||||
};
|
||||
|
||||
/* RX queue message types */
|
||||
struct virtio_can_rx {
|
||||
#define VIRTIO_CAN_RX 0x0101
|
||||
uint16_t msg_type;
|
||||
uint16_t length; /* 0..8 CC, 0..64 CAN-FD, 0..2048 CAN-XL, 12 bits */
|
||||
uint8_t reserved_classic_dlc; /* If CAN classic length = 8 then DLC can be 8..15 */
|
||||
uint8_t padding;
|
||||
uint16_t reserved_xl_priority; /* May be needed for CAN XL priority */
|
||||
uint32_t flags;
|
||||
uint32_t can_id;
|
||||
uint8_t sdu[] __counted_by_le(length);
|
||||
};
|
||||
|
||||
/* Control queue message types */
|
||||
struct virtio_can_control_out {
|
||||
#define VIRTIO_CAN_SET_CTRL_MODE_START 0x0201
|
||||
#define VIRTIO_CAN_SET_CTRL_MODE_STOP 0x0202
|
||||
uint16_t msg_type;
|
||||
};
|
||||
|
||||
struct virtio_can_control_in {
|
||||
uint8_t result;
|
||||
};
|
||||
|
||||
#endif /* #ifndef _LINUX_VIRTIO_VIRTIO_CAN_H */
|
||||
@@ -0,0 +1,121 @@
|
||||
#ifndef _LINUX_VIRTIO_CONFIG_H
|
||||
#define _LINUX_VIRTIO_CONFIG_H
|
||||
/* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so
|
||||
* anyone can use the definitions to implement compatible drivers/servers.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE. */
|
||||
|
||||
/* Virtio devices use a standardized configuration space to define their
|
||||
* features and pass configuration information, but each implementation can
|
||||
* store and access that space differently. */
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
/* Status byte for guest to report progress, and synchronize features. */
|
||||
/* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */
|
||||
#define VIRTIO_CONFIG_S_ACKNOWLEDGE 1
|
||||
/* We have found a driver for the device. */
|
||||
#define VIRTIO_CONFIG_S_DRIVER 2
|
||||
/* Driver has used its parts of the config, and is happy */
|
||||
#define VIRTIO_CONFIG_S_DRIVER_OK 4
|
||||
/* Driver has finished configuring features */
|
||||
#define VIRTIO_CONFIG_S_FEATURES_OK 8
|
||||
/* Device entered invalid state, driver must reset it */
|
||||
#define VIRTIO_CONFIG_S_NEEDS_RESET 0x40
|
||||
/* We've given up on this device. */
|
||||
#define VIRTIO_CONFIG_S_FAILED 0x80
|
||||
|
||||
/*
|
||||
* Virtio feature bits VIRTIO_TRANSPORT_F_START through
|
||||
* VIRTIO_TRANSPORT_F_END are reserved for the transport
|
||||
* being used (e.g. virtio_ring, virtio_pci etc.), the
|
||||
* rest are per-device feature bits.
|
||||
*/
|
||||
#define VIRTIO_TRANSPORT_F_START 28
|
||||
#define VIRTIO_TRANSPORT_F_END 42
|
||||
|
||||
#ifndef VIRTIO_CONFIG_NO_LEGACY
|
||||
/* Do we get callbacks when the ring is completely used, even if we've
|
||||
* suppressed them? */
|
||||
#define VIRTIO_F_NOTIFY_ON_EMPTY 24
|
||||
|
||||
/* Can the device handle any descriptor layout? */
|
||||
#define VIRTIO_F_ANY_LAYOUT 27
|
||||
#endif /* VIRTIO_CONFIG_NO_LEGACY */
|
||||
|
||||
/* v1.0 compliant. */
|
||||
#define VIRTIO_F_VERSION_1 32
|
||||
|
||||
/*
|
||||
* If clear - device has the platform DMA (e.g. IOMMU) bypass quirk feature.
|
||||
* If set - use platform DMA tools to access the memory.
|
||||
*
|
||||
* Note the reverse polarity (compared to most other features),
|
||||
* this is for compatibility with legacy systems.
|
||||
*/
|
||||
#define VIRTIO_F_ACCESS_PLATFORM 33
|
||||
/* Legacy name for VIRTIO_F_ACCESS_PLATFORM (for compatibility with old userspace) */
|
||||
#define VIRTIO_F_IOMMU_PLATFORM VIRTIO_F_ACCESS_PLATFORM
|
||||
|
||||
/* This feature indicates support for the packed virtqueue layout. */
|
||||
#define VIRTIO_F_RING_PACKED 34
|
||||
|
||||
/*
|
||||
* Inorder feature indicates that all buffers are used by the device
|
||||
* in the same order in which they have been made available.
|
||||
*/
|
||||
#define VIRTIO_F_IN_ORDER 35
|
||||
|
||||
/*
|
||||
* This feature indicates that memory accesses by the driver and the
|
||||
* device are ordered in a way described by the platform.
|
||||
*/
|
||||
#define VIRTIO_F_ORDER_PLATFORM 36
|
||||
|
||||
/*
|
||||
* Does the device support Single Root I/O Virtualization?
|
||||
*/
|
||||
#define VIRTIO_F_SR_IOV 37
|
||||
|
||||
/*
|
||||
* This feature indicates that the driver passes extra data (besides
|
||||
* identifying the virtqueue) in its device notifications.
|
||||
*/
|
||||
#define VIRTIO_F_NOTIFICATION_DATA 38
|
||||
|
||||
/* This feature indicates that the driver uses the data provided by the device
|
||||
* as a virtqueue identifier in available buffer notifications.
|
||||
*/
|
||||
#define VIRTIO_F_NOTIF_CONFIG_DATA 39
|
||||
|
||||
/*
|
||||
* This feature indicates that the driver can reset a queue individually.
|
||||
*/
|
||||
#define VIRTIO_F_RING_RESET 40
|
||||
|
||||
/*
|
||||
* This feature indicates that the device support administration virtqueues.
|
||||
*/
|
||||
#define VIRTIO_F_ADMIN_VQ 41
|
||||
|
||||
#endif /* _LINUX_VIRTIO_CONFIG_H */
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so
|
||||
* anyone can use the definitions to implement compatible drivers/servers:
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Copyright (C) Red Hat, Inc., 2009, 2010, 2011
|
||||
* Copyright (C) Amit Shah <[email protected]>, 2009, 2010, 2011
|
||||
*/
|
||||
#ifndef _LINUX_VIRTIO_CONSOLE_H
|
||||
#define _LINUX_VIRTIO_CONSOLE_H
|
||||
#include "standard-headers/linux/types.h"
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
|
||||
/* Feature bits */
|
||||
#define VIRTIO_CONSOLE_F_SIZE 0 /* Does host provide console size? */
|
||||
#define VIRTIO_CONSOLE_F_MULTIPORT 1 /* Does host provide multiple ports? */
|
||||
#define VIRTIO_CONSOLE_F_EMERG_WRITE 2 /* Does host support emergency write? */
|
||||
|
||||
#define VIRTIO_CONSOLE_BAD_ID (~(uint32_t)0)
|
||||
|
||||
struct virtio_console_config {
|
||||
/* columns of the screens */
|
||||
__virtio16 cols;
|
||||
/* rows of the screens */
|
||||
__virtio16 rows;
|
||||
/* max. number of ports this device can hold */
|
||||
__virtio32 max_nr_ports;
|
||||
/* emergency write register */
|
||||
__virtio32 emerg_wr;
|
||||
} QEMU_PACKED;
|
||||
|
||||
/*
|
||||
* A message that's passed between the Host and the Guest for a
|
||||
* particular port.
|
||||
*/
|
||||
struct virtio_console_control {
|
||||
__virtio32 id; /* Port number */
|
||||
__virtio16 event; /* The kind of control event (see below) */
|
||||
__virtio16 value; /* Extra information for the key */
|
||||
};
|
||||
|
||||
/* Some events for control messages */
|
||||
#define VIRTIO_CONSOLE_DEVICE_READY 0
|
||||
#define VIRTIO_CONSOLE_PORT_ADD 1
|
||||
#define VIRTIO_CONSOLE_PORT_REMOVE 2
|
||||
#define VIRTIO_CONSOLE_PORT_READY 3
|
||||
#define VIRTIO_CONSOLE_CONSOLE_PORT 4
|
||||
#define VIRTIO_CONSOLE_RESIZE 5
|
||||
#define VIRTIO_CONSOLE_PORT_OPEN 6
|
||||
#define VIRTIO_CONSOLE_PORT_NAME 7
|
||||
|
||||
|
||||
#endif /* _LINUX_VIRTIO_CONSOLE_H */
|
||||
@@ -0,0 +1,531 @@
|
||||
#ifndef _VIRTIO_CRYPTO_H
|
||||
#define _VIRTIO_CRYPTO_H
|
||||
/* This header is BSD licensed so anyone can use the definitions to implement
|
||||
* compatible drivers/servers.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#include "standard-headers/linux/types.h"
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
|
||||
|
||||
#define VIRTIO_CRYPTO_SERVICE_CIPHER 0
|
||||
#define VIRTIO_CRYPTO_SERVICE_HASH 1
|
||||
#define VIRTIO_CRYPTO_SERVICE_MAC 2
|
||||
#define VIRTIO_CRYPTO_SERVICE_AEAD 3
|
||||
#define VIRTIO_CRYPTO_SERVICE_AKCIPHER 4
|
||||
|
||||
#define VIRTIO_CRYPTO_OPCODE(service, op) (((service) << 8) | (op))
|
||||
|
||||
struct virtio_crypto_ctrl_header {
|
||||
#define VIRTIO_CRYPTO_CIPHER_CREATE_SESSION \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x02)
|
||||
#define VIRTIO_CRYPTO_CIPHER_DESTROY_SESSION \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x03)
|
||||
#define VIRTIO_CRYPTO_HASH_CREATE_SESSION \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x02)
|
||||
#define VIRTIO_CRYPTO_HASH_DESTROY_SESSION \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x03)
|
||||
#define VIRTIO_CRYPTO_MAC_CREATE_SESSION \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x02)
|
||||
#define VIRTIO_CRYPTO_MAC_DESTROY_SESSION \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x03)
|
||||
#define VIRTIO_CRYPTO_AEAD_CREATE_SESSION \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x02)
|
||||
#define VIRTIO_CRYPTO_AEAD_DESTROY_SESSION \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x03)
|
||||
#define VIRTIO_CRYPTO_AKCIPHER_CREATE_SESSION \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x04)
|
||||
#define VIRTIO_CRYPTO_AKCIPHER_DESTROY_SESSION \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x05)
|
||||
uint32_t opcode;
|
||||
uint32_t algo;
|
||||
uint32_t flag;
|
||||
/* data virtqueue id */
|
||||
uint32_t queue_id;
|
||||
};
|
||||
|
||||
struct virtio_crypto_cipher_session_para {
|
||||
#define VIRTIO_CRYPTO_NO_CIPHER 0
|
||||
#define VIRTIO_CRYPTO_CIPHER_ARC4 1
|
||||
#define VIRTIO_CRYPTO_CIPHER_AES_ECB 2
|
||||
#define VIRTIO_CRYPTO_CIPHER_AES_CBC 3
|
||||
#define VIRTIO_CRYPTO_CIPHER_AES_CTR 4
|
||||
#define VIRTIO_CRYPTO_CIPHER_DES_ECB 5
|
||||
#define VIRTIO_CRYPTO_CIPHER_DES_CBC 6
|
||||
#define VIRTIO_CRYPTO_CIPHER_3DES_ECB 7
|
||||
#define VIRTIO_CRYPTO_CIPHER_3DES_CBC 8
|
||||
#define VIRTIO_CRYPTO_CIPHER_3DES_CTR 9
|
||||
#define VIRTIO_CRYPTO_CIPHER_KASUMI_F8 10
|
||||
#define VIRTIO_CRYPTO_CIPHER_SNOW3G_UEA2 11
|
||||
#define VIRTIO_CRYPTO_CIPHER_AES_F8 12
|
||||
#define VIRTIO_CRYPTO_CIPHER_AES_XTS 13
|
||||
#define VIRTIO_CRYPTO_CIPHER_ZUC_EEA3 14
|
||||
uint32_t algo;
|
||||
/* length of key */
|
||||
uint32_t keylen;
|
||||
|
||||
#define VIRTIO_CRYPTO_OP_ENCRYPT 1
|
||||
#define VIRTIO_CRYPTO_OP_DECRYPT 2
|
||||
/* encrypt or decrypt */
|
||||
uint32_t op;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
struct virtio_crypto_session_input {
|
||||
/* Device-writable part */
|
||||
uint64_t session_id;
|
||||
uint32_t status;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
struct virtio_crypto_cipher_session_req {
|
||||
struct virtio_crypto_cipher_session_para para;
|
||||
uint8_t padding[32];
|
||||
};
|
||||
|
||||
struct virtio_crypto_hash_session_para {
|
||||
#define VIRTIO_CRYPTO_NO_HASH 0
|
||||
#define VIRTIO_CRYPTO_HASH_MD5 1
|
||||
#define VIRTIO_CRYPTO_HASH_SHA1 2
|
||||
#define VIRTIO_CRYPTO_HASH_SHA_224 3
|
||||
#define VIRTIO_CRYPTO_HASH_SHA_256 4
|
||||
#define VIRTIO_CRYPTO_HASH_SHA_384 5
|
||||
#define VIRTIO_CRYPTO_HASH_SHA_512 6
|
||||
#define VIRTIO_CRYPTO_HASH_SHA3_224 7
|
||||
#define VIRTIO_CRYPTO_HASH_SHA3_256 8
|
||||
#define VIRTIO_CRYPTO_HASH_SHA3_384 9
|
||||
#define VIRTIO_CRYPTO_HASH_SHA3_512 10
|
||||
#define VIRTIO_CRYPTO_HASH_SHA3_SHAKE128 11
|
||||
#define VIRTIO_CRYPTO_HASH_SHA3_SHAKE256 12
|
||||
uint32_t algo;
|
||||
/* hash result length */
|
||||
uint32_t hash_result_len;
|
||||
uint8_t padding[8];
|
||||
};
|
||||
|
||||
struct virtio_crypto_hash_create_session_req {
|
||||
struct virtio_crypto_hash_session_para para;
|
||||
uint8_t padding[40];
|
||||
};
|
||||
|
||||
struct virtio_crypto_mac_session_para {
|
||||
#define VIRTIO_CRYPTO_NO_MAC 0
|
||||
#define VIRTIO_CRYPTO_MAC_HMAC_MD5 1
|
||||
#define VIRTIO_CRYPTO_MAC_HMAC_SHA1 2
|
||||
#define VIRTIO_CRYPTO_MAC_HMAC_SHA_224 3
|
||||
#define VIRTIO_CRYPTO_MAC_HMAC_SHA_256 4
|
||||
#define VIRTIO_CRYPTO_MAC_HMAC_SHA_384 5
|
||||
#define VIRTIO_CRYPTO_MAC_HMAC_SHA_512 6
|
||||
#define VIRTIO_CRYPTO_MAC_CMAC_3DES 25
|
||||
#define VIRTIO_CRYPTO_MAC_CMAC_AES 26
|
||||
#define VIRTIO_CRYPTO_MAC_KASUMI_F9 27
|
||||
#define VIRTIO_CRYPTO_MAC_SNOW3G_UIA2 28
|
||||
#define VIRTIO_CRYPTO_MAC_GMAC_AES 41
|
||||
#define VIRTIO_CRYPTO_MAC_GMAC_TWOFISH 42
|
||||
#define VIRTIO_CRYPTO_MAC_CBCMAC_AES 49
|
||||
#define VIRTIO_CRYPTO_MAC_CBCMAC_KASUMI_F9 50
|
||||
#define VIRTIO_CRYPTO_MAC_XCBC_AES 53
|
||||
uint32_t algo;
|
||||
/* hash result length */
|
||||
uint32_t hash_result_len;
|
||||
/* length of authenticated key */
|
||||
uint32_t auth_key_len;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
struct virtio_crypto_mac_create_session_req {
|
||||
struct virtio_crypto_mac_session_para para;
|
||||
uint8_t padding[40];
|
||||
};
|
||||
|
||||
struct virtio_crypto_aead_session_para {
|
||||
#define VIRTIO_CRYPTO_NO_AEAD 0
|
||||
#define VIRTIO_CRYPTO_AEAD_GCM 1
|
||||
#define VIRTIO_CRYPTO_AEAD_CCM 2
|
||||
#define VIRTIO_CRYPTO_AEAD_CHACHA20_POLY1305 3
|
||||
uint32_t algo;
|
||||
/* length of key */
|
||||
uint32_t key_len;
|
||||
/* hash result length */
|
||||
uint32_t hash_result_len;
|
||||
/* length of the additional authenticated data (AAD) in bytes */
|
||||
uint32_t aad_len;
|
||||
/* encrypt or decrypt, See above VIRTIO_CRYPTO_OP_* */
|
||||
uint32_t op;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
struct virtio_crypto_aead_create_session_req {
|
||||
struct virtio_crypto_aead_session_para para;
|
||||
uint8_t padding[32];
|
||||
};
|
||||
|
||||
struct virtio_crypto_rsa_session_para {
|
||||
#define VIRTIO_CRYPTO_RSA_RAW_PADDING 0
|
||||
#define VIRTIO_CRYPTO_RSA_PKCS1_PADDING 1
|
||||
uint32_t padding_algo;
|
||||
|
||||
#define VIRTIO_CRYPTO_RSA_NO_HASH 0
|
||||
#define VIRTIO_CRYPTO_RSA_MD2 1
|
||||
#define VIRTIO_CRYPTO_RSA_MD3 2
|
||||
#define VIRTIO_CRYPTO_RSA_MD4 3
|
||||
#define VIRTIO_CRYPTO_RSA_MD5 4
|
||||
#define VIRTIO_CRYPTO_RSA_SHA1 5
|
||||
#define VIRTIO_CRYPTO_RSA_SHA256 6
|
||||
#define VIRTIO_CRYPTO_RSA_SHA384 7
|
||||
#define VIRTIO_CRYPTO_RSA_SHA512 8
|
||||
#define VIRTIO_CRYPTO_RSA_SHA224 9
|
||||
uint32_t hash_algo;
|
||||
};
|
||||
|
||||
struct virtio_crypto_ecdsa_session_para {
|
||||
#define VIRTIO_CRYPTO_CURVE_UNKNOWN 0
|
||||
#define VIRTIO_CRYPTO_CURVE_NIST_P192 1
|
||||
#define VIRTIO_CRYPTO_CURVE_NIST_P224 2
|
||||
#define VIRTIO_CRYPTO_CURVE_NIST_P256 3
|
||||
#define VIRTIO_CRYPTO_CURVE_NIST_P384 4
|
||||
#define VIRTIO_CRYPTO_CURVE_NIST_P521 5
|
||||
uint32_t curve_id;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
struct virtio_crypto_akcipher_session_para {
|
||||
#define VIRTIO_CRYPTO_NO_AKCIPHER 0
|
||||
#define VIRTIO_CRYPTO_AKCIPHER_RSA 1
|
||||
#define VIRTIO_CRYPTO_AKCIPHER_DSA 2
|
||||
#define VIRTIO_CRYPTO_AKCIPHER_ECDSA 3
|
||||
uint32_t algo;
|
||||
|
||||
#define VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC 1
|
||||
#define VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE 2
|
||||
uint32_t keytype;
|
||||
uint32_t keylen;
|
||||
|
||||
union {
|
||||
struct virtio_crypto_rsa_session_para rsa;
|
||||
struct virtio_crypto_ecdsa_session_para ecdsa;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct virtio_crypto_akcipher_create_session_req {
|
||||
struct virtio_crypto_akcipher_session_para para;
|
||||
uint8_t padding[36];
|
||||
};
|
||||
|
||||
struct virtio_crypto_alg_chain_session_para {
|
||||
#define VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER 1
|
||||
#define VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH 2
|
||||
uint32_t alg_chain_order;
|
||||
/* Plain hash */
|
||||
#define VIRTIO_CRYPTO_SYM_HASH_MODE_PLAIN 1
|
||||
/* Authenticated hash (mac) */
|
||||
#define VIRTIO_CRYPTO_SYM_HASH_MODE_AUTH 2
|
||||
/* Nested hash */
|
||||
#define VIRTIO_CRYPTO_SYM_HASH_MODE_NESTED 3
|
||||
uint32_t hash_mode;
|
||||
struct virtio_crypto_cipher_session_para cipher_param;
|
||||
union {
|
||||
struct virtio_crypto_hash_session_para hash_param;
|
||||
struct virtio_crypto_mac_session_para mac_param;
|
||||
uint8_t padding[16];
|
||||
} u;
|
||||
/* length of the additional authenticated data (AAD) in bytes */
|
||||
uint32_t aad_len;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
struct virtio_crypto_alg_chain_session_req {
|
||||
struct virtio_crypto_alg_chain_session_para para;
|
||||
};
|
||||
|
||||
struct virtio_crypto_sym_create_session_req {
|
||||
union {
|
||||
struct virtio_crypto_cipher_session_req cipher;
|
||||
struct virtio_crypto_alg_chain_session_req chain;
|
||||
uint8_t padding[48];
|
||||
} u;
|
||||
|
||||
/* Device-readable part */
|
||||
|
||||
/* No operation */
|
||||
#define VIRTIO_CRYPTO_SYM_OP_NONE 0
|
||||
/* Cipher only operation on the data */
|
||||
#define VIRTIO_CRYPTO_SYM_OP_CIPHER 1
|
||||
/*
|
||||
* Chain any cipher with any hash or mac operation. The order
|
||||
* depends on the value of alg_chain_order param
|
||||
*/
|
||||
#define VIRTIO_CRYPTO_SYM_OP_ALGORITHM_CHAINING 2
|
||||
uint32_t op_type;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
struct virtio_crypto_destroy_session_req {
|
||||
/* Device-readable part */
|
||||
uint64_t session_id;
|
||||
uint8_t padding[48];
|
||||
};
|
||||
|
||||
/* The request of the control virtqueue's packet */
|
||||
struct virtio_crypto_op_ctrl_req {
|
||||
struct virtio_crypto_ctrl_header header;
|
||||
|
||||
union {
|
||||
struct virtio_crypto_sym_create_session_req
|
||||
sym_create_session;
|
||||
struct virtio_crypto_hash_create_session_req
|
||||
hash_create_session;
|
||||
struct virtio_crypto_mac_create_session_req
|
||||
mac_create_session;
|
||||
struct virtio_crypto_aead_create_session_req
|
||||
aead_create_session;
|
||||
struct virtio_crypto_akcipher_create_session_req
|
||||
akcipher_create_session;
|
||||
struct virtio_crypto_destroy_session_req
|
||||
destroy_session;
|
||||
uint8_t padding[56];
|
||||
} u;
|
||||
};
|
||||
|
||||
struct virtio_crypto_op_header {
|
||||
#define VIRTIO_CRYPTO_CIPHER_ENCRYPT \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x00)
|
||||
#define VIRTIO_CRYPTO_CIPHER_DECRYPT \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_CIPHER, 0x01)
|
||||
#define VIRTIO_CRYPTO_HASH \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_HASH, 0x00)
|
||||
#define VIRTIO_CRYPTO_MAC \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_MAC, 0x00)
|
||||
#define VIRTIO_CRYPTO_AEAD_ENCRYPT \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x00)
|
||||
#define VIRTIO_CRYPTO_AEAD_DECRYPT \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x01)
|
||||
#define VIRTIO_CRYPTO_AKCIPHER_ENCRYPT \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x00)
|
||||
#define VIRTIO_CRYPTO_AKCIPHER_DECRYPT \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x01)
|
||||
/* akcipher sign/verify opcodes are deprecated */
|
||||
#define VIRTIO_CRYPTO_AKCIPHER_SIGN \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x02)
|
||||
#define VIRTIO_CRYPTO_AKCIPHER_VERIFY \
|
||||
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x03)
|
||||
uint32_t opcode;
|
||||
/* algo should be service-specific algorithms */
|
||||
uint32_t algo;
|
||||
/* session_id should be service-specific algorithms */
|
||||
uint64_t session_id;
|
||||
/* control flag to control the request */
|
||||
uint32_t flag;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
struct virtio_crypto_cipher_para {
|
||||
/*
|
||||
* Byte Length of valid IV/Counter
|
||||
*
|
||||
* For block ciphers in CBC or F8 mode, or for Kasumi in F8 mode, or for
|
||||
* SNOW3G in UEA2 mode, this is the length of the IV (which
|
||||
* must be the same as the block length of the cipher).
|
||||
* For block ciphers in CTR mode, this is the length of the counter
|
||||
* (which must be the same as the block length of the cipher).
|
||||
* For AES-XTS, this is the 128bit tweak, i, from IEEE Std 1619-2007.
|
||||
*
|
||||
* The IV/Counter will be updated after every partial cryptographic
|
||||
* operation.
|
||||
*/
|
||||
uint32_t iv_len;
|
||||
/* length of source data */
|
||||
uint32_t src_data_len;
|
||||
/* length of dst data */
|
||||
uint32_t dst_data_len;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
struct virtio_crypto_hash_para {
|
||||
/* length of source data */
|
||||
uint32_t src_data_len;
|
||||
/* hash result length */
|
||||
uint32_t hash_result_len;
|
||||
};
|
||||
|
||||
struct virtio_crypto_mac_para {
|
||||
struct virtio_crypto_hash_para hash;
|
||||
};
|
||||
|
||||
struct virtio_crypto_aead_para {
|
||||
/*
|
||||
* Byte Length of valid IV data pointed to by the below iv_addr
|
||||
* parameter.
|
||||
*
|
||||
* For GCM mode, this is either 12 (for 96-bit IVs) or 16, in which
|
||||
* case iv_addr points to J0.
|
||||
* For CCM mode, this is the length of the nonce, which can be in the
|
||||
* range 7 to 13 inclusive.
|
||||
*/
|
||||
uint32_t iv_len;
|
||||
/* length of additional auth data */
|
||||
uint32_t aad_len;
|
||||
/* length of source data */
|
||||
uint32_t src_data_len;
|
||||
/* length of dst data */
|
||||
uint32_t dst_data_len;
|
||||
};
|
||||
|
||||
struct virtio_crypto_cipher_data_req {
|
||||
/* Device-readable part */
|
||||
struct virtio_crypto_cipher_para para;
|
||||
uint8_t padding[24];
|
||||
};
|
||||
|
||||
struct virtio_crypto_hash_data_req {
|
||||
/* Device-readable part */
|
||||
struct virtio_crypto_hash_para para;
|
||||
uint8_t padding[40];
|
||||
};
|
||||
|
||||
struct virtio_crypto_mac_data_req {
|
||||
/* Device-readable part */
|
||||
struct virtio_crypto_mac_para para;
|
||||
uint8_t padding[40];
|
||||
};
|
||||
|
||||
struct virtio_crypto_alg_chain_data_para {
|
||||
uint32_t iv_len;
|
||||
/* Length of source data */
|
||||
uint32_t src_data_len;
|
||||
/* Length of destination data */
|
||||
uint32_t dst_data_len;
|
||||
/* Starting point for cipher processing in source data */
|
||||
uint32_t cipher_start_src_offset;
|
||||
/* Length of the source data that the cipher will be computed on */
|
||||
uint32_t len_to_cipher;
|
||||
/* Starting point for hash processing in source data */
|
||||
uint32_t hash_start_src_offset;
|
||||
/* Length of the source data that the hash will be computed on */
|
||||
uint32_t len_to_hash;
|
||||
/* Length of the additional auth data */
|
||||
uint32_t aad_len;
|
||||
/* Length of the hash result */
|
||||
uint32_t hash_result_len;
|
||||
uint32_t reserved;
|
||||
};
|
||||
|
||||
struct virtio_crypto_alg_chain_data_req {
|
||||
/* Device-readable part */
|
||||
struct virtio_crypto_alg_chain_data_para para;
|
||||
};
|
||||
|
||||
struct virtio_crypto_sym_data_req {
|
||||
union {
|
||||
struct virtio_crypto_cipher_data_req cipher;
|
||||
struct virtio_crypto_alg_chain_data_req chain;
|
||||
uint8_t padding[40];
|
||||
} u;
|
||||
|
||||
/* See above VIRTIO_CRYPTO_SYM_OP_* */
|
||||
uint32_t op_type;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
struct virtio_crypto_aead_data_req {
|
||||
/* Device-readable part */
|
||||
struct virtio_crypto_aead_para para;
|
||||
uint8_t padding[32];
|
||||
};
|
||||
|
||||
struct virtio_crypto_akcipher_para {
|
||||
uint32_t src_data_len;
|
||||
uint32_t dst_data_len;
|
||||
};
|
||||
|
||||
struct virtio_crypto_akcipher_data_req {
|
||||
struct virtio_crypto_akcipher_para para;
|
||||
uint8_t padding[40];
|
||||
};
|
||||
|
||||
/* The request of the data virtqueue's packet */
|
||||
struct virtio_crypto_op_data_req {
|
||||
struct virtio_crypto_op_header header;
|
||||
|
||||
union {
|
||||
struct virtio_crypto_sym_data_req sym_req;
|
||||
struct virtio_crypto_hash_data_req hash_req;
|
||||
struct virtio_crypto_mac_data_req mac_req;
|
||||
struct virtio_crypto_aead_data_req aead_req;
|
||||
struct virtio_crypto_akcipher_data_req akcipher_req;
|
||||
uint8_t padding[48];
|
||||
} u;
|
||||
};
|
||||
|
||||
#define VIRTIO_CRYPTO_OK 0
|
||||
#define VIRTIO_CRYPTO_ERR 1
|
||||
#define VIRTIO_CRYPTO_BADMSG 2
|
||||
#define VIRTIO_CRYPTO_NOTSUPP 3
|
||||
#define VIRTIO_CRYPTO_INVSESS 4 /* Invalid session id */
|
||||
#define VIRTIO_CRYPTO_NOSPC 5 /* no free session ID */
|
||||
#define VIRTIO_CRYPTO_KEY_REJECTED 6 /* Signature verification failed */
|
||||
|
||||
/* The accelerator hardware is ready */
|
||||
#define VIRTIO_CRYPTO_S_HW_READY (1 << 0)
|
||||
|
||||
struct virtio_crypto_config {
|
||||
/* See VIRTIO_CRYPTO_OP_* above */
|
||||
uint32_t status;
|
||||
|
||||
/*
|
||||
* Maximum number of data queue
|
||||
*/
|
||||
uint32_t max_dataqueues;
|
||||
|
||||
/*
|
||||
* Specifies the services mask which the device support,
|
||||
* see VIRTIO_CRYPTO_SERVICE_* above
|
||||
*/
|
||||
uint32_t crypto_services;
|
||||
|
||||
/* Detailed algorithms mask */
|
||||
uint32_t cipher_algo_l;
|
||||
uint32_t cipher_algo_h;
|
||||
uint32_t hash_algo;
|
||||
uint32_t mac_algo_l;
|
||||
uint32_t mac_algo_h;
|
||||
uint32_t aead_algo;
|
||||
/* Maximum length of cipher key */
|
||||
uint32_t max_cipher_key_len;
|
||||
/* Maximum length of authenticated key */
|
||||
uint32_t max_auth_key_len;
|
||||
uint32_t akcipher_algo;
|
||||
/* Maximum size of each crypto request's content */
|
||||
uint64_t max_size;
|
||||
};
|
||||
|
||||
struct virtio_crypto_inhdr {
|
||||
/* See VIRTIO_CRYPTO_* above */
|
||||
uint8_t status;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
|
||||
|
||||
#ifndef _LINUX_VIRTIO_FS_H
|
||||
#define _LINUX_VIRTIO_FS_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
|
||||
struct virtio_fs_config {
|
||||
/* Filesystem name (UTF-8, not NUL-terminated, padded with NULs) */
|
||||
uint8_t tag[36];
|
||||
|
||||
/* Number of request queues */
|
||||
uint32_t num_request_queues;
|
||||
} QEMU_PACKED;
|
||||
|
||||
/* For the id field in virtio_pci_shm_cap */
|
||||
#define VIRTIO_FS_SHMCAP_ID_CACHE 0
|
||||
|
||||
#endif /* _LINUX_VIRTIO_FS_H */
|
||||
@@ -0,0 +1,72 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
|
||||
#ifndef _LINUX_VIRTIO_GPIO_H
|
||||
#define _LINUX_VIRTIO_GPIO_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
/* Virtio GPIO Feature bits */
|
||||
#define VIRTIO_GPIO_F_IRQ 0
|
||||
|
||||
/* Virtio GPIO request types */
|
||||
#define VIRTIO_GPIO_MSG_GET_NAMES 0x0001
|
||||
#define VIRTIO_GPIO_MSG_GET_DIRECTION 0x0002
|
||||
#define VIRTIO_GPIO_MSG_SET_DIRECTION 0x0003
|
||||
#define VIRTIO_GPIO_MSG_GET_VALUE 0x0004
|
||||
#define VIRTIO_GPIO_MSG_SET_VALUE 0x0005
|
||||
#define VIRTIO_GPIO_MSG_IRQ_TYPE 0x0006
|
||||
|
||||
/* Possible values of the status field */
|
||||
#define VIRTIO_GPIO_STATUS_OK 0x0
|
||||
#define VIRTIO_GPIO_STATUS_ERR 0x1
|
||||
|
||||
/* Direction types */
|
||||
#define VIRTIO_GPIO_DIRECTION_NONE 0x00
|
||||
#define VIRTIO_GPIO_DIRECTION_OUT 0x01
|
||||
#define VIRTIO_GPIO_DIRECTION_IN 0x02
|
||||
|
||||
/* Virtio GPIO IRQ types */
|
||||
#define VIRTIO_GPIO_IRQ_TYPE_NONE 0x00
|
||||
#define VIRTIO_GPIO_IRQ_TYPE_EDGE_RISING 0x01
|
||||
#define VIRTIO_GPIO_IRQ_TYPE_EDGE_FALLING 0x02
|
||||
#define VIRTIO_GPIO_IRQ_TYPE_EDGE_BOTH 0x03
|
||||
#define VIRTIO_GPIO_IRQ_TYPE_LEVEL_HIGH 0x04
|
||||
#define VIRTIO_GPIO_IRQ_TYPE_LEVEL_LOW 0x08
|
||||
|
||||
struct virtio_gpio_config {
|
||||
uint16_t ngpio;
|
||||
uint8_t padding[2];
|
||||
uint32_t gpio_names_size;
|
||||
};
|
||||
|
||||
/* Virtio GPIO Request / Response */
|
||||
struct virtio_gpio_request {
|
||||
uint16_t type;
|
||||
uint16_t gpio;
|
||||
uint32_t value;
|
||||
};
|
||||
|
||||
struct virtio_gpio_response {
|
||||
uint8_t status;
|
||||
uint8_t value;
|
||||
};
|
||||
|
||||
struct virtio_gpio_response_get_names {
|
||||
uint8_t status;
|
||||
uint8_t value[];
|
||||
};
|
||||
|
||||
/* Virtio GPIO IRQ Request / Response */
|
||||
struct virtio_gpio_irq_request {
|
||||
uint16_t gpio;
|
||||
};
|
||||
|
||||
struct virtio_gpio_irq_response {
|
||||
uint8_t status;
|
||||
};
|
||||
|
||||
/* Possible values of the interrupt status field */
|
||||
#define VIRTIO_GPIO_IRQ_STATUS_INVALID 0x0
|
||||
#define VIRTIO_GPIO_IRQ_STATUS_VALID 0x1
|
||||
|
||||
#endif /* _LINUX_VIRTIO_GPIO_H */
|
||||
@@ -0,0 +1,469 @@
|
||||
/*
|
||||
* Virtio GPU Device
|
||||
*
|
||||
* Copyright Red Hat, Inc. 2013-2014
|
||||
*
|
||||
* Authors:
|
||||
* Dave Airlie <[email protected]>
|
||||
* Gerd Hoffmann <[email protected]>
|
||||
*
|
||||
* This header is BSD licensed so anyone can use the definitions
|
||||
* to implement compatible drivers/servers:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef VIRTIO_GPU_HW_H
|
||||
#define VIRTIO_GPU_HW_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
/*
|
||||
* VIRTIO_GPU_CMD_CTX_*
|
||||
* VIRTIO_GPU_CMD_*_3D
|
||||
*/
|
||||
#define VIRTIO_GPU_F_VIRGL 0
|
||||
|
||||
/*
|
||||
* VIRTIO_GPU_CMD_GET_EDID
|
||||
*/
|
||||
#define VIRTIO_GPU_F_EDID 1
|
||||
/*
|
||||
* VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID
|
||||
*/
|
||||
#define VIRTIO_GPU_F_RESOURCE_UUID 2
|
||||
|
||||
/*
|
||||
* VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB
|
||||
*/
|
||||
#define VIRTIO_GPU_F_RESOURCE_BLOB 3
|
||||
/*
|
||||
* VIRTIO_GPU_CMD_CREATE_CONTEXT with
|
||||
* context_init and multiple timelines
|
||||
*/
|
||||
#define VIRTIO_GPU_F_CONTEXT_INIT 4
|
||||
/*
|
||||
* The device provides a valid blob_alignment
|
||||
* field in its configuration and both
|
||||
* VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB and
|
||||
* VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB requests
|
||||
* must be aligned to that value.
|
||||
*/
|
||||
#define VIRTIO_GPU_F_BLOB_ALIGNMENT 5
|
||||
|
||||
enum virtio_gpu_ctrl_type {
|
||||
VIRTIO_GPU_UNDEFINED = 0,
|
||||
|
||||
/* 2d commands */
|
||||
VIRTIO_GPU_CMD_GET_DISPLAY_INFO = 0x0100,
|
||||
VIRTIO_GPU_CMD_RESOURCE_CREATE_2D,
|
||||
VIRTIO_GPU_CMD_RESOURCE_UNREF,
|
||||
VIRTIO_GPU_CMD_SET_SCANOUT,
|
||||
VIRTIO_GPU_CMD_RESOURCE_FLUSH,
|
||||
VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D,
|
||||
VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING,
|
||||
VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING,
|
||||
VIRTIO_GPU_CMD_GET_CAPSET_INFO,
|
||||
VIRTIO_GPU_CMD_GET_CAPSET,
|
||||
VIRTIO_GPU_CMD_GET_EDID,
|
||||
VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID,
|
||||
VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB,
|
||||
VIRTIO_GPU_CMD_SET_SCANOUT_BLOB,
|
||||
|
||||
/* 3d commands */
|
||||
VIRTIO_GPU_CMD_CTX_CREATE = 0x0200,
|
||||
VIRTIO_GPU_CMD_CTX_DESTROY,
|
||||
VIRTIO_GPU_CMD_CTX_ATTACH_RESOURCE,
|
||||
VIRTIO_GPU_CMD_CTX_DETACH_RESOURCE,
|
||||
VIRTIO_GPU_CMD_RESOURCE_CREATE_3D,
|
||||
VIRTIO_GPU_CMD_TRANSFER_TO_HOST_3D,
|
||||
VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D,
|
||||
VIRTIO_GPU_CMD_SUBMIT_3D,
|
||||
VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB,
|
||||
VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB,
|
||||
|
||||
/* cursor commands */
|
||||
VIRTIO_GPU_CMD_UPDATE_CURSOR = 0x0300,
|
||||
VIRTIO_GPU_CMD_MOVE_CURSOR,
|
||||
|
||||
/* success responses */
|
||||
VIRTIO_GPU_RESP_OK_NODATA = 0x1100,
|
||||
VIRTIO_GPU_RESP_OK_DISPLAY_INFO,
|
||||
VIRTIO_GPU_RESP_OK_CAPSET_INFO,
|
||||
VIRTIO_GPU_RESP_OK_CAPSET,
|
||||
VIRTIO_GPU_RESP_OK_EDID,
|
||||
VIRTIO_GPU_RESP_OK_RESOURCE_UUID,
|
||||
VIRTIO_GPU_RESP_OK_MAP_INFO,
|
||||
|
||||
/* error responses */
|
||||
VIRTIO_GPU_RESP_ERR_UNSPEC = 0x1200,
|
||||
VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY,
|
||||
VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID,
|
||||
VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID,
|
||||
VIRTIO_GPU_RESP_ERR_INVALID_CONTEXT_ID,
|
||||
VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER,
|
||||
};
|
||||
|
||||
enum virtio_gpu_shm_id {
|
||||
VIRTIO_GPU_SHM_ID_UNDEFINED = 0,
|
||||
/*
|
||||
* VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB
|
||||
* VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB
|
||||
*/
|
||||
VIRTIO_GPU_SHM_ID_HOST_VISIBLE = 1
|
||||
};
|
||||
|
||||
#define VIRTIO_GPU_FLAG_FENCE (1 << 0)
|
||||
/*
|
||||
* If the following flag is set, then ring_idx contains the index
|
||||
* of the command ring that needs to used when creating the fence
|
||||
*/
|
||||
#define VIRTIO_GPU_FLAG_INFO_RING_IDX (1 << 1)
|
||||
|
||||
struct virtio_gpu_ctrl_hdr {
|
||||
uint32_t type;
|
||||
uint32_t flags;
|
||||
uint64_t fence_id;
|
||||
uint32_t ctx_id;
|
||||
uint8_t ring_idx;
|
||||
uint8_t padding[3];
|
||||
};
|
||||
|
||||
/* data passed in the cursor vq */
|
||||
|
||||
struct virtio_gpu_cursor_pos {
|
||||
uint32_t scanout_id;
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_UPDATE_CURSOR, VIRTIO_GPU_CMD_MOVE_CURSOR */
|
||||
struct virtio_gpu_update_cursor {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
struct virtio_gpu_cursor_pos pos; /* update & move */
|
||||
uint32_t resource_id; /* update only */
|
||||
uint32_t hot_x; /* update only */
|
||||
uint32_t hot_y; /* update only */
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
/* data passed in the control vq, 2d related */
|
||||
|
||||
struct virtio_gpu_rect {
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_RESOURCE_UNREF */
|
||||
struct virtio_gpu_resource_unref {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t resource_id;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_RESOURCE_CREATE_2D: create a 2d resource with a format */
|
||||
struct virtio_gpu_resource_create_2d {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t resource_id;
|
||||
uint32_t format;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_SET_SCANOUT */
|
||||
struct virtio_gpu_set_scanout {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
struct virtio_gpu_rect r;
|
||||
uint32_t scanout_id;
|
||||
uint32_t resource_id;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_RESOURCE_FLUSH */
|
||||
struct virtio_gpu_resource_flush {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
struct virtio_gpu_rect r;
|
||||
uint32_t resource_id;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D: simple transfer to_host */
|
||||
struct virtio_gpu_transfer_to_host_2d {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
struct virtio_gpu_rect r;
|
||||
uint64_t offset;
|
||||
uint32_t resource_id;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
struct virtio_gpu_mem_entry {
|
||||
uint64_t addr;
|
||||
uint32_t length;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING */
|
||||
struct virtio_gpu_resource_attach_backing {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t resource_id;
|
||||
uint32_t nr_entries;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING */
|
||||
struct virtio_gpu_resource_detach_backing {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t resource_id;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_RESP_OK_DISPLAY_INFO */
|
||||
#define VIRTIO_GPU_MAX_SCANOUTS 16
|
||||
struct virtio_gpu_resp_display_info {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
struct virtio_gpu_display_one {
|
||||
struct virtio_gpu_rect r;
|
||||
uint32_t enabled;
|
||||
uint32_t flags;
|
||||
} pmodes[VIRTIO_GPU_MAX_SCANOUTS];
|
||||
};
|
||||
|
||||
/* data passed in the control vq, 3d related */
|
||||
|
||||
struct virtio_gpu_box {
|
||||
uint32_t x, y, z;
|
||||
uint32_t w, h, d;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_TRANSFER_TO_HOST_3D, VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D */
|
||||
struct virtio_gpu_transfer_host_3d {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
struct virtio_gpu_box box;
|
||||
uint64_t offset;
|
||||
uint32_t resource_id;
|
||||
uint32_t level;
|
||||
uint32_t stride;
|
||||
uint32_t layer_stride;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_RESOURCE_CREATE_3D */
|
||||
#define VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP (1 << 0)
|
||||
struct virtio_gpu_resource_create_3d {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t resource_id;
|
||||
uint32_t target;
|
||||
uint32_t format;
|
||||
uint32_t bind;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t depth;
|
||||
uint32_t array_size;
|
||||
uint32_t last_level;
|
||||
uint32_t nr_samples;
|
||||
uint32_t flags;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_CTX_CREATE */
|
||||
#define VIRTIO_GPU_CONTEXT_INIT_CAPSET_ID_MASK 0x000000ff
|
||||
struct virtio_gpu_ctx_create {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t nlen;
|
||||
uint32_t context_init;
|
||||
char debug_name[64];
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_CTX_DESTROY */
|
||||
struct virtio_gpu_ctx_destroy {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_CTX_ATTACH_RESOURCE, VIRTIO_GPU_CMD_CTX_DETACH_RESOURCE */
|
||||
struct virtio_gpu_ctx_resource {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t resource_id;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_SUBMIT_3D */
|
||||
struct virtio_gpu_cmd_submit {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t size;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
#define VIRTIO_GPU_CAPSET_VIRGL 1
|
||||
#define VIRTIO_GPU_CAPSET_VIRGL2 2
|
||||
#define VIRTIO_GPU_CAPSET_GFXSTREAM_VULKAN 3
|
||||
#define VIRTIO_GPU_CAPSET_VENUS 4
|
||||
#define VIRTIO_GPU_CAPSET_CROSS_DOMAIN 5
|
||||
#define VIRTIO_GPU_CAPSET_DRM 6
|
||||
|
||||
/* VIRTIO_GPU_CMD_GET_CAPSET_INFO */
|
||||
struct virtio_gpu_get_capset_info {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t capset_index;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_RESP_OK_CAPSET_INFO */
|
||||
struct virtio_gpu_resp_capset_info {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t capset_id;
|
||||
uint32_t capset_max_version;
|
||||
uint32_t capset_max_size;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_GET_CAPSET */
|
||||
struct virtio_gpu_get_capset {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t capset_id;
|
||||
uint32_t capset_version;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_RESP_OK_CAPSET */
|
||||
struct virtio_gpu_resp_capset {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint8_t capset_data[];
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_GET_EDID */
|
||||
struct virtio_gpu_cmd_get_edid {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t scanout;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_RESP_OK_EDID */
|
||||
struct virtio_gpu_resp_edid {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t size;
|
||||
uint32_t padding;
|
||||
uint8_t edid[1024];
|
||||
};
|
||||
|
||||
#define VIRTIO_GPU_EVENT_DISPLAY (1 << 0)
|
||||
|
||||
struct virtio_gpu_config {
|
||||
uint32_t events_read;
|
||||
uint32_t events_clear;
|
||||
uint32_t num_scanouts;
|
||||
uint32_t num_capsets;
|
||||
uint32_t blob_alignment;
|
||||
};
|
||||
|
||||
/* simple formats for fbcon/X use */
|
||||
enum virtio_gpu_formats {
|
||||
VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM = 1,
|
||||
VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM = 2,
|
||||
VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM = 3,
|
||||
VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM = 4,
|
||||
|
||||
VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM = 67,
|
||||
VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM = 68,
|
||||
|
||||
VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM = 121,
|
||||
VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM = 134,
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID */
|
||||
struct virtio_gpu_resource_assign_uuid {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t resource_id;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_RESP_OK_RESOURCE_UUID */
|
||||
struct virtio_gpu_resp_resource_uuid {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint8_t uuid[16];
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB */
|
||||
struct virtio_gpu_resource_create_blob {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t resource_id;
|
||||
#define VIRTIO_GPU_BLOB_MEM_GUEST 0x0001
|
||||
#define VIRTIO_GPU_BLOB_MEM_HOST3D 0x0002
|
||||
#define VIRTIO_GPU_BLOB_MEM_HOST3D_GUEST 0x0003
|
||||
|
||||
#define VIRTIO_GPU_BLOB_FLAG_USE_MAPPABLE 0x0001
|
||||
#define VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE 0x0002
|
||||
#define VIRTIO_GPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004
|
||||
/* zero is invalid blob mem */
|
||||
uint32_t blob_mem;
|
||||
uint32_t blob_flags;
|
||||
uint32_t nr_entries;
|
||||
uint64_t blob_id;
|
||||
uint64_t size;
|
||||
/*
|
||||
* sizeof(nr_entries * virtio_gpu_mem_entry) bytes follow
|
||||
*/
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_SET_SCANOUT_BLOB */
|
||||
struct virtio_gpu_set_scanout_blob {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
struct virtio_gpu_rect r;
|
||||
uint32_t scanout_id;
|
||||
uint32_t resource_id;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t format;
|
||||
uint32_t padding;
|
||||
uint32_t strides[4];
|
||||
uint32_t offsets[4];
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB */
|
||||
struct virtio_gpu_resource_map_blob {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t resource_id;
|
||||
uint32_t padding;
|
||||
uint64_t offset;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_RESP_OK_MAP_INFO */
|
||||
#define VIRTIO_GPU_MAP_CACHE_MASK 0x0f
|
||||
#define VIRTIO_GPU_MAP_CACHE_NONE 0x00
|
||||
#define VIRTIO_GPU_MAP_CACHE_CACHED 0x01
|
||||
#define VIRTIO_GPU_MAP_CACHE_UNCACHED 0x02
|
||||
#define VIRTIO_GPU_MAP_CACHE_WC 0x03
|
||||
struct virtio_gpu_resp_map_info {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t map_info;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
/* VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB */
|
||||
struct virtio_gpu_resource_unmap_blob {
|
||||
struct virtio_gpu_ctrl_hdr hdr;
|
||||
uint32_t resource_id;
|
||||
uint32_t padding;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,47 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */
|
||||
/*
|
||||
* Definitions for virtio I2C Adpter
|
||||
*
|
||||
* Copyright (c) 2021 Intel Corporation. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_VIRTIO_I2C_H
|
||||
#define _LINUX_VIRTIO_I2C_H
|
||||
|
||||
#include "standard-headers/linux/const.h"
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
/* Virtio I2C Feature bits */
|
||||
#define VIRTIO_I2C_F_ZERO_LENGTH_REQUEST 0
|
||||
|
||||
/* The bit 0 of the @virtio_i2c_out_hdr.@flags, used to group the requests */
|
||||
#define VIRTIO_I2C_FLAGS_FAIL_NEXT _BITUL(0)
|
||||
|
||||
/* The bit 1 of the @virtio_i2c_out_hdr.@flags, used to mark a buffer as read */
|
||||
#define VIRTIO_I2C_FLAGS_M_RD _BITUL(1)
|
||||
|
||||
/**
|
||||
* struct virtio_i2c_out_hdr - the virtio I2C message OUT header
|
||||
* @addr: the controlled device address
|
||||
* @padding: used to pad to full dword
|
||||
* @flags: used for feature extensibility
|
||||
*/
|
||||
struct virtio_i2c_out_hdr {
|
||||
uint16_t addr;
|
||||
uint16_t padding;
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct virtio_i2c_in_hdr - the virtio I2C message IN header
|
||||
* @status: the processing result from the backend
|
||||
*/
|
||||
struct virtio_i2c_in_hdr {
|
||||
uint8_t status;
|
||||
};
|
||||
|
||||
/* The final status written by the device */
|
||||
#define VIRTIO_I2C_MSG_OK 0
|
||||
#define VIRTIO_I2C_MSG_ERR 1
|
||||
|
||||
#endif /* _LINUX_VIRTIO_I2C_H */
|
||||
@@ -0,0 +1,85 @@
|
||||
#ifndef _LINUX_VIRTIO_IDS_H
|
||||
#define _LINUX_VIRTIO_IDS_H
|
||||
/*
|
||||
* Virtio IDs
|
||||
*
|
||||
* This header is BSD licensed so anyone can use the definitions to implement
|
||||
* compatible drivers/servers.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE. */
|
||||
|
||||
#define VIRTIO_ID_NET 1 /* virtio net */
|
||||
#define VIRTIO_ID_BLOCK 2 /* virtio block */
|
||||
#define VIRTIO_ID_CONSOLE 3 /* virtio console */
|
||||
#define VIRTIO_ID_RNG 4 /* virtio rng */
|
||||
#define VIRTIO_ID_BALLOON 5 /* virtio balloon */
|
||||
#define VIRTIO_ID_IOMEM 6 /* virtio ioMemory */
|
||||
#define VIRTIO_ID_RPMSG 7 /* virtio remote processor messaging */
|
||||
#define VIRTIO_ID_SCSI 8 /* virtio scsi */
|
||||
#define VIRTIO_ID_9P 9 /* 9p virtio console */
|
||||
#define VIRTIO_ID_MAC80211_WLAN 10 /* virtio WLAN MAC */
|
||||
#define VIRTIO_ID_RPROC_SERIAL 11 /* virtio remoteproc serial link */
|
||||
#define VIRTIO_ID_CAIF 12 /* Virtio caif */
|
||||
#define VIRTIO_ID_MEMORY_BALLOON 13 /* virtio memory balloon */
|
||||
#define VIRTIO_ID_GPU 16 /* virtio GPU */
|
||||
#define VIRTIO_ID_CLOCK 17 /* virtio clock/timer */
|
||||
#define VIRTIO_ID_INPUT 18 /* virtio input */
|
||||
#define VIRTIO_ID_VSOCK 19 /* virtio vsock transport */
|
||||
#define VIRTIO_ID_CRYPTO 20 /* virtio crypto */
|
||||
#define VIRTIO_ID_SIGNAL_DIST 21 /* virtio signal distribution device */
|
||||
#define VIRTIO_ID_PSTORE 22 /* virtio pstore device */
|
||||
#define VIRTIO_ID_IOMMU 23 /* virtio IOMMU */
|
||||
#define VIRTIO_ID_MEM 24 /* virtio mem */
|
||||
#define VIRTIO_ID_SOUND 25 /* virtio sound */
|
||||
#define VIRTIO_ID_FS 26 /* virtio filesystem */
|
||||
#define VIRTIO_ID_PMEM 27 /* virtio pmem */
|
||||
#define VIRTIO_ID_RPMB 28 /* virtio rpmb */
|
||||
#define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */
|
||||
#define VIRTIO_ID_VIDEO_ENCODER 30 /* virtio video encoder */
|
||||
#define VIRTIO_ID_VIDEO_DECODER 31 /* virtio video decoder */
|
||||
#define VIRTIO_ID_SCMI 32 /* virtio SCMI */
|
||||
#define VIRTIO_ID_NITRO_SEC_MOD 33 /* virtio nitro secure module*/
|
||||
#define VIRTIO_ID_I2C_ADAPTER 34 /* virtio i2c adapter */
|
||||
#define VIRTIO_ID_WATCHDOG 35 /* virtio watchdog */
|
||||
#define VIRTIO_ID_CAN 36 /* virtio can */
|
||||
#define VIRTIO_ID_DMABUF 37 /* virtio dmabuf */
|
||||
#define VIRTIO_ID_PARAM_SERV 38 /* virtio parameter server */
|
||||
#define VIRTIO_ID_AUDIO_POLICY 39 /* virtio audio policy */
|
||||
#define VIRTIO_ID_BT 40 /* virtio bluetooth */
|
||||
#define VIRTIO_ID_GPIO 41 /* virtio gpio */
|
||||
#define VIRTIO_ID_SPI 45 /* virtio spi */
|
||||
|
||||
/*
|
||||
* Virtio Transitional IDs
|
||||
*/
|
||||
|
||||
#define VIRTIO_TRANS_ID_NET 0x1000 /* transitional virtio net */
|
||||
#define VIRTIO_TRANS_ID_BLOCK 0x1001 /* transitional virtio block */
|
||||
#define VIRTIO_TRANS_ID_BALLOON 0x1002 /* transitional virtio balloon */
|
||||
#define VIRTIO_TRANS_ID_CONSOLE 0x1003 /* transitional virtio console */
|
||||
#define VIRTIO_TRANS_ID_SCSI 0x1004 /* transitional virtio SCSI */
|
||||
#define VIRTIO_TRANS_ID_RNG 0x1005 /* transitional virtio rng */
|
||||
#define VIRTIO_TRANS_ID_9P 0x1009 /* transitional virtio 9p console */
|
||||
|
||||
#endif /* _LINUX_VIRTIO_IDS_H */
|
||||
@@ -0,0 +1,76 @@
|
||||
#ifndef _LINUX_VIRTIO_INPUT_H
|
||||
#define _LINUX_VIRTIO_INPUT_H
|
||||
/* This header is BSD licensed so anyone can use the definitions to implement
|
||||
* compatible drivers/servers.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE. */
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
enum virtio_input_config_select {
|
||||
VIRTIO_INPUT_CFG_UNSET = 0x00,
|
||||
VIRTIO_INPUT_CFG_ID_NAME = 0x01,
|
||||
VIRTIO_INPUT_CFG_ID_SERIAL = 0x02,
|
||||
VIRTIO_INPUT_CFG_ID_DEVIDS = 0x03,
|
||||
VIRTIO_INPUT_CFG_PROP_BITS = 0x10,
|
||||
VIRTIO_INPUT_CFG_EV_BITS = 0x11,
|
||||
VIRTIO_INPUT_CFG_ABS_INFO = 0x12,
|
||||
};
|
||||
|
||||
struct virtio_input_absinfo {
|
||||
uint32_t min;
|
||||
uint32_t max;
|
||||
uint32_t fuzz;
|
||||
uint32_t flat;
|
||||
uint32_t res;
|
||||
};
|
||||
|
||||
struct virtio_input_devids {
|
||||
uint16_t bustype;
|
||||
uint16_t vendor;
|
||||
uint16_t product;
|
||||
uint16_t version;
|
||||
};
|
||||
|
||||
struct virtio_input_config {
|
||||
uint8_t select;
|
||||
uint8_t subsel;
|
||||
uint8_t size;
|
||||
uint8_t reserved[5];
|
||||
union {
|
||||
char string[128];
|
||||
uint8_t bitmap[128];
|
||||
struct virtio_input_absinfo abs;
|
||||
struct virtio_input_devids ids;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct virtio_input_event {
|
||||
uint16_t type;
|
||||
uint16_t code;
|
||||
uint32_t value;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_VIRTIO_INPUT_H */
|
||||
@@ -0,0 +1,171 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/*
|
||||
* Virtio-iommu definition v0.12
|
||||
*
|
||||
* Copyright (C) 2019 Arm Ltd.
|
||||
*/
|
||||
#ifndef _LINUX_VIRTIO_IOMMU_H
|
||||
#define _LINUX_VIRTIO_IOMMU_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
/* Feature bits */
|
||||
#define VIRTIO_IOMMU_F_INPUT_RANGE 0
|
||||
#define VIRTIO_IOMMU_F_DOMAIN_RANGE 1
|
||||
#define VIRTIO_IOMMU_F_MAP_UNMAP 2
|
||||
#define VIRTIO_IOMMU_F_BYPASS 3
|
||||
#define VIRTIO_IOMMU_F_PROBE 4
|
||||
#define VIRTIO_IOMMU_F_MMIO 5
|
||||
#define VIRTIO_IOMMU_F_BYPASS_CONFIG 6
|
||||
|
||||
struct virtio_iommu_range_64 {
|
||||
uint64_t start;
|
||||
uint64_t end;
|
||||
};
|
||||
|
||||
struct virtio_iommu_range_32 {
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
};
|
||||
|
||||
struct virtio_iommu_config {
|
||||
/* Supported page sizes */
|
||||
uint64_t page_size_mask;
|
||||
/* Supported IOVA range */
|
||||
struct virtio_iommu_range_64 input_range;
|
||||
/* Max domain ID size */
|
||||
struct virtio_iommu_range_32 domain_range;
|
||||
/* Probe buffer size */
|
||||
uint32_t probe_size;
|
||||
uint8_t bypass;
|
||||
uint8_t reserved[3];
|
||||
};
|
||||
|
||||
/* Request types */
|
||||
#define VIRTIO_IOMMU_T_ATTACH 0x01
|
||||
#define VIRTIO_IOMMU_T_DETACH 0x02
|
||||
#define VIRTIO_IOMMU_T_MAP 0x03
|
||||
#define VIRTIO_IOMMU_T_UNMAP 0x04
|
||||
#define VIRTIO_IOMMU_T_PROBE 0x05
|
||||
|
||||
/* Status types */
|
||||
#define VIRTIO_IOMMU_S_OK 0x00
|
||||
#define VIRTIO_IOMMU_S_IOERR 0x01
|
||||
#define VIRTIO_IOMMU_S_UNSUPP 0x02
|
||||
#define VIRTIO_IOMMU_S_DEVERR 0x03
|
||||
#define VIRTIO_IOMMU_S_INVAL 0x04
|
||||
#define VIRTIO_IOMMU_S_RANGE 0x05
|
||||
#define VIRTIO_IOMMU_S_NOENT 0x06
|
||||
#define VIRTIO_IOMMU_S_FAULT 0x07
|
||||
#define VIRTIO_IOMMU_S_NOMEM 0x08
|
||||
|
||||
struct virtio_iommu_req_head {
|
||||
uint8_t type;
|
||||
uint8_t reserved[3];
|
||||
};
|
||||
|
||||
struct virtio_iommu_req_tail {
|
||||
uint8_t status;
|
||||
uint8_t reserved[3];
|
||||
};
|
||||
|
||||
#define VIRTIO_IOMMU_ATTACH_F_BYPASS (1 << 0)
|
||||
|
||||
struct virtio_iommu_req_attach {
|
||||
struct virtio_iommu_req_head head;
|
||||
uint32_t domain;
|
||||
uint32_t endpoint;
|
||||
uint32_t flags;
|
||||
uint8_t reserved[4];
|
||||
struct virtio_iommu_req_tail tail;
|
||||
};
|
||||
|
||||
struct virtio_iommu_req_detach {
|
||||
struct virtio_iommu_req_head head;
|
||||
uint32_t domain;
|
||||
uint32_t endpoint;
|
||||
uint8_t reserved[8];
|
||||
struct virtio_iommu_req_tail tail;
|
||||
};
|
||||
|
||||
#define VIRTIO_IOMMU_MAP_F_READ (1 << 0)
|
||||
#define VIRTIO_IOMMU_MAP_F_WRITE (1 << 1)
|
||||
#define VIRTIO_IOMMU_MAP_F_MMIO (1 << 2)
|
||||
|
||||
#define VIRTIO_IOMMU_MAP_F_MASK (VIRTIO_IOMMU_MAP_F_READ | \
|
||||
VIRTIO_IOMMU_MAP_F_WRITE | \
|
||||
VIRTIO_IOMMU_MAP_F_MMIO)
|
||||
|
||||
struct virtio_iommu_req_map {
|
||||
struct virtio_iommu_req_head head;
|
||||
uint32_t domain;
|
||||
uint64_t virt_start;
|
||||
uint64_t virt_end;
|
||||
uint64_t phys_start;
|
||||
uint32_t flags;
|
||||
struct virtio_iommu_req_tail tail;
|
||||
};
|
||||
|
||||
struct virtio_iommu_req_unmap {
|
||||
struct virtio_iommu_req_head head;
|
||||
uint32_t domain;
|
||||
uint64_t virt_start;
|
||||
uint64_t virt_end;
|
||||
uint8_t reserved[4];
|
||||
struct virtio_iommu_req_tail tail;
|
||||
};
|
||||
|
||||
#define VIRTIO_IOMMU_PROBE_T_NONE 0
|
||||
#define VIRTIO_IOMMU_PROBE_T_RESV_MEM 1
|
||||
|
||||
#define VIRTIO_IOMMU_PROBE_T_MASK 0xfff
|
||||
|
||||
struct virtio_iommu_probe_property {
|
||||
uint16_t type;
|
||||
uint16_t length;
|
||||
};
|
||||
|
||||
#define VIRTIO_IOMMU_RESV_MEM_T_RESERVED 0
|
||||
#define VIRTIO_IOMMU_RESV_MEM_T_MSI 1
|
||||
|
||||
struct virtio_iommu_probe_resv_mem {
|
||||
struct virtio_iommu_probe_property head;
|
||||
uint8_t subtype;
|
||||
uint8_t reserved[3];
|
||||
uint64_t start;
|
||||
uint64_t end;
|
||||
};
|
||||
|
||||
struct virtio_iommu_req_probe {
|
||||
struct virtio_iommu_req_head head;
|
||||
uint32_t endpoint;
|
||||
uint8_t reserved[64];
|
||||
|
||||
uint8_t properties[];
|
||||
|
||||
/*
|
||||
* Tail follows the variable-length properties array. No padding,
|
||||
* property lengths are all aligned on 8 bytes.
|
||||
*/
|
||||
};
|
||||
|
||||
/* Fault types */
|
||||
#define VIRTIO_IOMMU_FAULT_R_UNKNOWN 0
|
||||
#define VIRTIO_IOMMU_FAULT_R_DOMAIN 1
|
||||
#define VIRTIO_IOMMU_FAULT_R_MAPPING 2
|
||||
|
||||
#define VIRTIO_IOMMU_FAULT_F_READ (1 << 0)
|
||||
#define VIRTIO_IOMMU_FAULT_F_WRITE (1 << 1)
|
||||
#define VIRTIO_IOMMU_FAULT_F_EXEC (1 << 2)
|
||||
#define VIRTIO_IOMMU_FAULT_F_ADDRESS (1 << 8)
|
||||
|
||||
struct virtio_iommu_fault {
|
||||
uint8_t reason;
|
||||
uint8_t reserved[3];
|
||||
uint32_t flags;
|
||||
uint32_t endpoint;
|
||||
uint8_t reserved2[4];
|
||||
uint64_t address;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,216 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/*
|
||||
* Virtio Mem Device
|
||||
*
|
||||
* Copyright Red Hat, Inc. 2020
|
||||
*
|
||||
* Authors:
|
||||
* David Hildenbrand <[email protected]>
|
||||
*
|
||||
* This header is BSD licensed so anyone can use the definitions
|
||||
* to implement compatible drivers/servers:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_VIRTIO_MEM_H
|
||||
#define _LINUX_VIRTIO_MEM_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
|
||||
/*
|
||||
* Each virtio-mem device manages a dedicated region in physical address
|
||||
* space. Each device can belong to a single NUMA node, multiple devices
|
||||
* for a single NUMA node are possible. A virtio-mem device is like a
|
||||
* "resizable DIMM" consisting of small memory blocks that can be plugged
|
||||
* or unplugged. The device driver is responsible for (un)plugging memory
|
||||
* blocks on demand.
|
||||
*
|
||||
* Virtio-mem devices can only operate on their assigned memory region in
|
||||
* order to (un)plug memory. A device cannot (un)plug memory belonging to
|
||||
* other devices.
|
||||
*
|
||||
* The "region_size" corresponds to the maximum amount of memory that can
|
||||
* be provided by a device. The "size" corresponds to the amount of memory
|
||||
* that is currently plugged. "requested_size" corresponds to a request
|
||||
* from the device to the device driver to (un)plug blocks. The
|
||||
* device driver should try to (un)plug blocks in order to reach the
|
||||
* "requested_size". It is impossible to plug more memory than requested.
|
||||
*
|
||||
* The "usable_region_size" represents the memory region that can actually
|
||||
* be used to (un)plug memory. It is always at least as big as the
|
||||
* "requested_size" and will grow dynamically. It will only shrink when
|
||||
* explicitly triggered (VIRTIO_MEM_REQ_UNPLUG).
|
||||
*
|
||||
* There are no guarantees what will happen if unplugged memory is
|
||||
* read/written. In general, unplugged memory should not be touched, because
|
||||
* the resulting action is undefined. There is one exception: without
|
||||
* VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, unplugged memory inside the usable
|
||||
* region can be read, to simplify creation of memory dumps.
|
||||
*
|
||||
* It can happen that the device cannot process a request, because it is
|
||||
* busy. The device driver has to retry later.
|
||||
*
|
||||
* Usually, during system resets all memory will get unplugged, so the
|
||||
* device driver can start with a clean state. However, in specific
|
||||
* scenarios (if the device is busy) it can happen that the device still
|
||||
* has memory plugged. The device driver can request to unplug all memory
|
||||
* (VIRTIO_MEM_REQ_UNPLUG) - which might take a while to succeed if the
|
||||
* device is busy.
|
||||
*/
|
||||
|
||||
/* --- virtio-mem: feature bits --- */
|
||||
|
||||
/* node_id is an ACPI PXM and is valid */
|
||||
#define VIRTIO_MEM_F_ACPI_PXM 0
|
||||
/* unplugged memory must not be accessed */
|
||||
#define VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE 1
|
||||
/* plugged memory will remain plugged when suspending+resuming */
|
||||
#define VIRTIO_MEM_F_PERSISTENT_SUSPEND 2
|
||||
|
||||
|
||||
/* --- virtio-mem: guest -> host requests --- */
|
||||
|
||||
/* request to plug memory blocks */
|
||||
#define VIRTIO_MEM_REQ_PLUG 0
|
||||
/* request to unplug memory blocks */
|
||||
#define VIRTIO_MEM_REQ_UNPLUG 1
|
||||
/* request to unplug all blocks and shrink the usable size */
|
||||
#define VIRTIO_MEM_REQ_UNPLUG_ALL 2
|
||||
/* request information about the plugged state of memory blocks */
|
||||
#define VIRTIO_MEM_REQ_STATE 3
|
||||
|
||||
struct virtio_mem_req_plug {
|
||||
__virtio64 addr;
|
||||
__virtio16 nb_blocks;
|
||||
__virtio16 padding[3];
|
||||
};
|
||||
|
||||
struct virtio_mem_req_unplug {
|
||||
__virtio64 addr;
|
||||
__virtio16 nb_blocks;
|
||||
__virtio16 padding[3];
|
||||
};
|
||||
|
||||
struct virtio_mem_req_state {
|
||||
__virtio64 addr;
|
||||
__virtio16 nb_blocks;
|
||||
__virtio16 padding[3];
|
||||
};
|
||||
|
||||
struct virtio_mem_req {
|
||||
__virtio16 type;
|
||||
__virtio16 padding[3];
|
||||
|
||||
union {
|
||||
struct virtio_mem_req_plug plug;
|
||||
struct virtio_mem_req_unplug unplug;
|
||||
struct virtio_mem_req_state state;
|
||||
} u;
|
||||
};
|
||||
|
||||
|
||||
/* --- virtio-mem: host -> guest response --- */
|
||||
|
||||
/*
|
||||
* Request processed successfully, applicable for
|
||||
* - VIRTIO_MEM_REQ_PLUG
|
||||
* - VIRTIO_MEM_REQ_UNPLUG
|
||||
* - VIRTIO_MEM_REQ_UNPLUG_ALL
|
||||
* - VIRTIO_MEM_REQ_STATE
|
||||
*/
|
||||
#define VIRTIO_MEM_RESP_ACK 0
|
||||
/*
|
||||
* Request denied - e.g. trying to plug more than requested, applicable for
|
||||
* - VIRTIO_MEM_REQ_PLUG
|
||||
*/
|
||||
#define VIRTIO_MEM_RESP_NACK 1
|
||||
/*
|
||||
* Request cannot be processed right now, try again later, applicable for
|
||||
* - VIRTIO_MEM_REQ_PLUG
|
||||
* - VIRTIO_MEM_REQ_UNPLUG
|
||||
* - VIRTIO_MEM_REQ_UNPLUG_ALL
|
||||
*/
|
||||
#define VIRTIO_MEM_RESP_BUSY 2
|
||||
/*
|
||||
* Error in request (e.g. addresses/alignment), applicable for
|
||||
* - VIRTIO_MEM_REQ_PLUG
|
||||
* - VIRTIO_MEM_REQ_UNPLUG
|
||||
* - VIRTIO_MEM_REQ_STATE
|
||||
*/
|
||||
#define VIRTIO_MEM_RESP_ERROR 3
|
||||
|
||||
|
||||
/* State of memory blocks is "plugged" */
|
||||
#define VIRTIO_MEM_STATE_PLUGGED 0
|
||||
/* State of memory blocks is "unplugged" */
|
||||
#define VIRTIO_MEM_STATE_UNPLUGGED 1
|
||||
/* State of memory blocks is "mixed" */
|
||||
#define VIRTIO_MEM_STATE_MIXED 2
|
||||
|
||||
struct virtio_mem_resp_state {
|
||||
__virtio16 state;
|
||||
};
|
||||
|
||||
struct virtio_mem_resp {
|
||||
__virtio16 type;
|
||||
__virtio16 padding[3];
|
||||
|
||||
union {
|
||||
struct virtio_mem_resp_state state;
|
||||
} u;
|
||||
};
|
||||
|
||||
/* --- virtio-mem: configuration --- */
|
||||
|
||||
struct virtio_mem_config {
|
||||
/* Block size and alignment. Cannot change. */
|
||||
uint64_t block_size;
|
||||
/* Valid with VIRTIO_MEM_F_ACPI_PXM. Cannot change. */
|
||||
uint16_t node_id;
|
||||
uint8_t padding[6];
|
||||
/* Start address of the memory region. Cannot change. */
|
||||
uint64_t addr;
|
||||
/* Region size (maximum). Cannot change. */
|
||||
uint64_t region_size;
|
||||
/*
|
||||
* Currently usable region size. Can grow up to region_size. Can
|
||||
* shrink due to VIRTIO_MEM_REQ_UNPLUG_ALL (in which case no config
|
||||
* update will be sent).
|
||||
*/
|
||||
uint64_t usable_region_size;
|
||||
/*
|
||||
* Currently used size. Changes due to plug/unplug requests, but no
|
||||
* config updates will be sent.
|
||||
*/
|
||||
uint64_t plugged_size;
|
||||
/* Requested size. New plug requests cannot exceed it. Can change. */
|
||||
uint64_t requested_size;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_VIRTIO_MEM_H */
|
||||
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Virtio platform device driver
|
||||
*
|
||||
* Copyright 2011, ARM Ltd.
|
||||
*
|
||||
* Based on Virtio PCI driver by Anthony Liguori, copyright IBM Corp. 2007
|
||||
*
|
||||
* This header is BSD licensed so anyone can use the definitions to implement
|
||||
* compatible drivers/servers.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_VIRTIO_MMIO_H
|
||||
#define _LINUX_VIRTIO_MMIO_H
|
||||
|
||||
/*
|
||||
* Control registers
|
||||
*/
|
||||
|
||||
/* Magic value ("virt" string) - Read Only */
|
||||
#define VIRTIO_MMIO_MAGIC_VALUE 0x000
|
||||
|
||||
/* Virtio device version - Read Only */
|
||||
#define VIRTIO_MMIO_VERSION 0x004
|
||||
|
||||
/* Virtio device ID - Read Only */
|
||||
#define VIRTIO_MMIO_DEVICE_ID 0x008
|
||||
|
||||
/* Virtio vendor ID - Read Only */
|
||||
#define VIRTIO_MMIO_VENDOR_ID 0x00c
|
||||
|
||||
/* Bitmask of the features supported by the device (host)
|
||||
* (32 bits per set) - Read Only */
|
||||
#define VIRTIO_MMIO_DEVICE_FEATURES 0x010
|
||||
|
||||
/* Device (host) features set selector - Write Only */
|
||||
#define VIRTIO_MMIO_DEVICE_FEATURES_SEL 0x014
|
||||
|
||||
/* Bitmask of features activated by the driver (guest)
|
||||
* (32 bits per set) - Write Only */
|
||||
#define VIRTIO_MMIO_DRIVER_FEATURES 0x020
|
||||
|
||||
/* Activated features set selector - Write Only */
|
||||
#define VIRTIO_MMIO_DRIVER_FEATURES_SEL 0x024
|
||||
|
||||
|
||||
#ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */
|
||||
|
||||
/* Guest's memory page size in bytes - Write Only */
|
||||
#define VIRTIO_MMIO_GUEST_PAGE_SIZE 0x028
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Queue selector - Write Only */
|
||||
#define VIRTIO_MMIO_QUEUE_SEL 0x030
|
||||
|
||||
/* Maximum size of the currently selected queue - Read Only */
|
||||
#define VIRTIO_MMIO_QUEUE_NUM_MAX 0x034
|
||||
|
||||
/* Queue size for the currently selected queue - Write Only */
|
||||
#define VIRTIO_MMIO_QUEUE_NUM 0x038
|
||||
|
||||
|
||||
#ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */
|
||||
|
||||
/* Used Ring alignment for the currently selected queue - Write Only */
|
||||
#define VIRTIO_MMIO_QUEUE_ALIGN 0x03c
|
||||
|
||||
/* Guest's PFN for the currently selected queue - Read Write */
|
||||
#define VIRTIO_MMIO_QUEUE_PFN 0x040
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Ready bit for the currently selected queue - Read Write */
|
||||
#define VIRTIO_MMIO_QUEUE_READY 0x044
|
||||
|
||||
/* Queue notifier - Write Only */
|
||||
#define VIRTIO_MMIO_QUEUE_NOTIFY 0x050
|
||||
|
||||
/* Interrupt status - Read Only */
|
||||
#define VIRTIO_MMIO_INTERRUPT_STATUS 0x060
|
||||
|
||||
/* Interrupt acknowledge - Write Only */
|
||||
#define VIRTIO_MMIO_INTERRUPT_ACK 0x064
|
||||
|
||||
/* Device status register - Read Write */
|
||||
#define VIRTIO_MMIO_STATUS 0x070
|
||||
|
||||
/* Selected queue's Descriptor Table address, 64 bits in two halves */
|
||||
#define VIRTIO_MMIO_QUEUE_DESC_LOW 0x080
|
||||
#define VIRTIO_MMIO_QUEUE_DESC_HIGH 0x084
|
||||
|
||||
/* Selected queue's Available Ring address, 64 bits in two halves */
|
||||
#define VIRTIO_MMIO_QUEUE_AVAIL_LOW 0x090
|
||||
#define VIRTIO_MMIO_QUEUE_AVAIL_HIGH 0x094
|
||||
|
||||
/* Selected queue's Used Ring address, 64 bits in two halves */
|
||||
#define VIRTIO_MMIO_QUEUE_USED_LOW 0x0a0
|
||||
#define VIRTIO_MMIO_QUEUE_USED_HIGH 0x0a4
|
||||
|
||||
/* Shared memory region id */
|
||||
#define VIRTIO_MMIO_SHM_SEL 0x0ac
|
||||
|
||||
/* Shared memory region length, 64 bits in two halves */
|
||||
#define VIRTIO_MMIO_SHM_LEN_LOW 0x0b0
|
||||
#define VIRTIO_MMIO_SHM_LEN_HIGH 0x0b4
|
||||
|
||||
/* Shared memory region base address, 64 bits in two halves */
|
||||
#define VIRTIO_MMIO_SHM_BASE_LOW 0x0b8
|
||||
#define VIRTIO_MMIO_SHM_BASE_HIGH 0x0bc
|
||||
|
||||
/* Configuration atomicity value */
|
||||
#define VIRTIO_MMIO_CONFIG_GENERATION 0x0fc
|
||||
|
||||
/* The config space is defined by each driver as
|
||||
* the per-driver configuration space - Read Write */
|
||||
#define VIRTIO_MMIO_CONFIG 0x100
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Interrupt flags (re: interrupt status & acknowledge registers)
|
||||
*/
|
||||
|
||||
#define VIRTIO_MMIO_INT_VRING (1 << 0)
|
||||
#define VIRTIO_MMIO_INT_CONFIG (1 << 1)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,599 @@
|
||||
#ifndef _LINUX_VIRTIO_NET_H
|
||||
#define _LINUX_VIRTIO_NET_H
|
||||
/* This header is BSD licensed so anyone can use the definitions to implement
|
||||
* compatible drivers/servers.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE. */
|
||||
#include "standard-headers/linux/types.h"
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
#include "standard-headers/linux/if_ether.h"
|
||||
|
||||
/* The feature bitmap for virtio net */
|
||||
#define VIRTIO_NET_F_CSUM 0 /* Host handles pkts w/ partial csum */
|
||||
#define VIRTIO_NET_F_GUEST_CSUM 1 /* Guest handles pkts w/ partial csum */
|
||||
#define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2 /* Dynamic offload configuration. */
|
||||
#define VIRTIO_NET_F_MTU 3 /* Initial MTU advice */
|
||||
#define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */
|
||||
#define VIRTIO_NET_F_GUEST_TSO4 7 /* Guest can handle TSOv4 in. */
|
||||
#define VIRTIO_NET_F_GUEST_TSO6 8 /* Guest can handle TSOv6 in. */
|
||||
#define VIRTIO_NET_F_GUEST_ECN 9 /* Guest can handle TSO[6] w/ ECN in. */
|
||||
#define VIRTIO_NET_F_GUEST_UFO 10 /* Guest can handle UFO in. */
|
||||
#define VIRTIO_NET_F_HOST_TSO4 11 /* Host can handle TSOv4 in. */
|
||||
#define VIRTIO_NET_F_HOST_TSO6 12 /* Host can handle TSOv6 in. */
|
||||
#define VIRTIO_NET_F_HOST_ECN 13 /* Host can handle TSO[6] w/ ECN in. */
|
||||
#define VIRTIO_NET_F_HOST_UFO 14 /* Host can handle UFO in. */
|
||||
#define VIRTIO_NET_F_MRG_RXBUF 15 /* Host can merge receive buffers. */
|
||||
#define VIRTIO_NET_F_STATUS 16 /* virtio_net_config.status available */
|
||||
#define VIRTIO_NET_F_CTRL_VQ 17 /* Control channel available */
|
||||
#define VIRTIO_NET_F_CTRL_RX 18 /* Control channel RX mode support */
|
||||
#define VIRTIO_NET_F_CTRL_VLAN 19 /* Control channel VLAN filtering */
|
||||
#define VIRTIO_NET_F_CTRL_RX_EXTRA 20 /* Extra RX mode control support */
|
||||
#define VIRTIO_NET_F_GUEST_ANNOUNCE 21 /* Guest can announce device on the
|
||||
* network */
|
||||
#define VIRTIO_NET_F_MQ 22 /* Device supports Receive Flow
|
||||
* Steering */
|
||||
#define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */
|
||||
#define VIRTIO_NET_F_DEVICE_STATS 50 /* Device can provide device-level statistics. */
|
||||
#define VIRTIO_NET_F_VQ_NOTF_COAL 52 /* Device supports virtqueue notification coalescing */
|
||||
#define VIRTIO_NET_F_NOTF_COAL 53 /* Device supports notifications coalescing */
|
||||
#define VIRTIO_NET_F_GUEST_USO4 54 /* Guest can handle USOv4 in. */
|
||||
#define VIRTIO_NET_F_GUEST_USO6 55 /* Guest can handle USOv6 in. */
|
||||
#define VIRTIO_NET_F_HOST_USO 56 /* Host can handle USO in. */
|
||||
#define VIRTIO_NET_F_HASH_REPORT 57 /* Supports hash report */
|
||||
#define VIRTIO_NET_F_GUEST_HDRLEN 59 /* Guest provides the exact hdr_len value. */
|
||||
#define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */
|
||||
#define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */
|
||||
#define VIRTIO_NET_F_STANDBY 62 /* Act as standby for another device
|
||||
* with the same MAC.
|
||||
*/
|
||||
#define VIRTIO_NET_F_SPEED_DUPLEX 63 /* Device set linkspeed and duplex */
|
||||
#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO 65 /* Driver can receive
|
||||
* GSO-over-UDP-tunnel packets
|
||||
*/
|
||||
#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM 66 /* Driver handles
|
||||
* GSO-over-UDP-tunnel
|
||||
* packets with partial csum
|
||||
* for the outer header
|
||||
*/
|
||||
#define VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO 67 /* Device can receive
|
||||
* GSO-over-UDP-tunnel packets
|
||||
*/
|
||||
#define VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM 68 /* Device handles
|
||||
* GSO-over-UDP-tunnel
|
||||
* packets with partial csum
|
||||
* for the outer header
|
||||
*/
|
||||
|
||||
/* Offloads bits corresponding to VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO{,_CSUM}
|
||||
* features
|
||||
*/
|
||||
#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_MAPPED 46
|
||||
#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM_MAPPED 47
|
||||
|
||||
#ifndef VIRTIO_NET_NO_LEGACY
|
||||
#define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */
|
||||
#endif /* VIRTIO_NET_NO_LEGACY */
|
||||
|
||||
#define VIRTIO_NET_S_LINK_UP 1 /* Link is up */
|
||||
#define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */
|
||||
|
||||
/* supported/enabled hash types */
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_IPv4 (1 << 0)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_TCPv4 (1 << 1)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_UDPv4 (1 << 2)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_IPv6 (1 << 3)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_TCPv6 (1 << 4)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_UDPv6 (1 << 5)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_IP_EX (1 << 6)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_TCP_EX (1 << 7)
|
||||
#define VIRTIO_NET_RSS_HASH_TYPE_UDP_EX (1 << 8)
|
||||
|
||||
struct virtio_net_config {
|
||||
/* The config defining mac address (if VIRTIO_NET_F_MAC) */
|
||||
uint8_t mac[ETH_ALEN];
|
||||
/* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */
|
||||
__virtio16 status;
|
||||
/* Maximum number of each of transmit and receive queues;
|
||||
* see VIRTIO_NET_F_MQ and VIRTIO_NET_CTRL_MQ.
|
||||
* Legal values are between 1 and 0x8000
|
||||
*/
|
||||
__virtio16 max_virtqueue_pairs;
|
||||
/* Default maximum transmit unit advice */
|
||||
__virtio16 mtu;
|
||||
/*
|
||||
* speed, in units of 1Mb. All values 0 to INT_MAX are legal.
|
||||
* Any other value stands for unknown.
|
||||
*/
|
||||
uint32_t speed;
|
||||
/*
|
||||
* 0x00 - half duplex
|
||||
* 0x01 - full duplex
|
||||
* Any other value stands for unknown.
|
||||
*/
|
||||
uint8_t duplex;
|
||||
/* maximum size of RSS key */
|
||||
uint8_t rss_max_key_size;
|
||||
/* maximum number of indirection table entries */
|
||||
uint16_t rss_max_indirection_table_length;
|
||||
/* bitmask of supported VIRTIO_NET_RSS_HASH_ types */
|
||||
uint32_t supported_hash_types;
|
||||
} QEMU_PACKED;
|
||||
|
||||
/*
|
||||
* This header comes first in the scatter-gather list. If you don't
|
||||
* specify GSO or CSUM features, you can simply ignore the header.
|
||||
*
|
||||
* This is bitwise-equivalent to the legacy struct virtio_net_hdr_mrg_rxbuf,
|
||||
* only flattened.
|
||||
*/
|
||||
struct virtio_net_hdr_v1 {
|
||||
#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */
|
||||
#define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */
|
||||
#define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc info in csum_ fields */
|
||||
#define VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM 8 /* UDP tunnel csum offload */
|
||||
uint8_t flags;
|
||||
#define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */
|
||||
#define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */
|
||||
#define VIRTIO_NET_HDR_GSO_UDP 3 /* GSO frame, IPv4 UDP (UFO) */
|
||||
#define VIRTIO_NET_HDR_GSO_TCPV6 4 /* GSO frame, IPv6 TCP */
|
||||
#define VIRTIO_NET_HDR_GSO_UDP_L4 5 /* GSO frame, IPv4& IPv6 UDP (USO) */
|
||||
#define VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4 0x20 /* UDPv4 tunnel present */
|
||||
#define VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6 0x40 /* UDPv6 tunnel present */
|
||||
#define VIRTIO_NET_HDR_GSO_UDP_TUNNEL (VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4 | \
|
||||
VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6)
|
||||
#define VIRTIO_NET_HDR_GSO_ECN 0x80 /* TCP has ECN set */
|
||||
uint8_t gso_type;
|
||||
__virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */
|
||||
__virtio16 gso_size; /* Bytes to append to hdr_len per frame */
|
||||
union {
|
||||
struct {
|
||||
__virtio16 csum_start;
|
||||
__virtio16 csum_offset;
|
||||
};
|
||||
/* Checksum calculation */
|
||||
struct {
|
||||
/* Position to start checksumming from */
|
||||
__virtio16 start;
|
||||
/* Offset after that to place checksum */
|
||||
__virtio16 offset;
|
||||
} csum;
|
||||
/* Receive Segment Coalescing */
|
||||
struct {
|
||||
/* Number of coalesced segments */
|
||||
uint16_t segments;
|
||||
/* Number of duplicated acks */
|
||||
uint16_t dup_acks;
|
||||
} rsc;
|
||||
};
|
||||
__virtio16 num_buffers; /* Number of merged rx buffers */
|
||||
};
|
||||
|
||||
struct virtio_net_hdr_v1_hash {
|
||||
struct virtio_net_hdr_v1 hdr;
|
||||
uint16_t hash_value_lo;
|
||||
uint16_t hash_value_hi;
|
||||
#define VIRTIO_NET_HASH_REPORT_NONE 0
|
||||
#define VIRTIO_NET_HASH_REPORT_IPv4 1
|
||||
#define VIRTIO_NET_HASH_REPORT_TCPv4 2
|
||||
#define VIRTIO_NET_HASH_REPORT_UDPv4 3
|
||||
#define VIRTIO_NET_HASH_REPORT_IPv6 4
|
||||
#define VIRTIO_NET_HASH_REPORT_TCPv6 5
|
||||
#define VIRTIO_NET_HASH_REPORT_UDPv6 6
|
||||
#define VIRTIO_NET_HASH_REPORT_IPv6_EX 7
|
||||
#define VIRTIO_NET_HASH_REPORT_TCPv6_EX 8
|
||||
#define VIRTIO_NET_HASH_REPORT_UDPv6_EX 9
|
||||
uint16_t hash_report;
|
||||
uint16_t padding;
|
||||
};
|
||||
|
||||
struct virtio_net_hdr_v1_hash_tunnel {
|
||||
struct virtio_net_hdr_v1_hash hash_hdr;
|
||||
uint16_t outer_th_offset;
|
||||
uint16_t inner_nh_offset;
|
||||
};
|
||||
|
||||
#ifndef VIRTIO_NET_NO_LEGACY
|
||||
/* This header comes first in the scatter-gather list.
|
||||
* For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must
|
||||
* be the first element of the scatter-gather list. If you don't
|
||||
* specify GSO or CSUM features, you can simply ignore the header. */
|
||||
struct virtio_net_hdr {
|
||||
/* See VIRTIO_NET_HDR_F_* */
|
||||
uint8_t flags;
|
||||
/* See VIRTIO_NET_HDR_GSO_* */
|
||||
uint8_t gso_type;
|
||||
__virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */
|
||||
__virtio16 gso_size; /* Bytes to append to hdr_len per frame */
|
||||
__virtio16 csum_start; /* Position to start checksumming from */
|
||||
__virtio16 csum_offset; /* Offset after that to place checksum */
|
||||
};
|
||||
|
||||
/* This is the version of the header to use when the MRG_RXBUF
|
||||
* feature has been negotiated. */
|
||||
struct virtio_net_hdr_mrg_rxbuf {
|
||||
struct virtio_net_hdr hdr;
|
||||
__virtio16 num_buffers; /* Number of merged rx buffers */
|
||||
};
|
||||
#endif /* ...VIRTIO_NET_NO_LEGACY */
|
||||
|
||||
/*
|
||||
* Control virtqueue data structures
|
||||
*
|
||||
* The control virtqueue expects a header in the first sg entry
|
||||
* and an ack/status response in the last entry. Data for the
|
||||
* command goes in between.
|
||||
*/
|
||||
struct virtio_net_ctrl_hdr {
|
||||
uint8_t class;
|
||||
uint8_t cmd;
|
||||
} QEMU_PACKED;
|
||||
|
||||
typedef uint8_t virtio_net_ctrl_ack;
|
||||
|
||||
#define VIRTIO_NET_OK 0
|
||||
#define VIRTIO_NET_ERR 1
|
||||
|
||||
/*
|
||||
* Control the RX mode, ie. promisucous, allmulti, etc...
|
||||
* All commands require an "out" sg entry containing a 1 byte
|
||||
* state value, zero = disable, non-zero = enable. Commands
|
||||
* 0 and 1 are supported with the VIRTIO_NET_F_CTRL_RX feature.
|
||||
* Commands 2-5 are added with VIRTIO_NET_F_CTRL_RX_EXTRA.
|
||||
*/
|
||||
#define VIRTIO_NET_CTRL_RX 0
|
||||
#define VIRTIO_NET_CTRL_RX_PROMISC 0
|
||||
#define VIRTIO_NET_CTRL_RX_ALLMULTI 1
|
||||
#define VIRTIO_NET_CTRL_RX_ALLUNI 2
|
||||
#define VIRTIO_NET_CTRL_RX_NOMULTI 3
|
||||
#define VIRTIO_NET_CTRL_RX_NOUNI 4
|
||||
#define VIRTIO_NET_CTRL_RX_NOBCAST 5
|
||||
|
||||
/*
|
||||
* Control the MAC
|
||||
*
|
||||
* The MAC filter table is managed by the hypervisor, the guest should
|
||||
* assume the size is infinite. Filtering should be considered
|
||||
* non-perfect, ie. based on hypervisor resources, the guest may
|
||||
* received packets from sources not specified in the filter list.
|
||||
*
|
||||
* In addition to the class/cmd header, the TABLE_SET command requires
|
||||
* two out scatterlists. Each contains a 4 byte count of entries followed
|
||||
* by a concatenated byte stream of the ETH_ALEN MAC addresses. The
|
||||
* first sg list contains unicast addresses, the second is for multicast.
|
||||
* This functionality is present if the VIRTIO_NET_F_CTRL_RX feature
|
||||
* is available.
|
||||
*
|
||||
* The ADDR_SET command requests one out scatterlist, it contains a
|
||||
* 6 bytes MAC address. This functionality is present if the
|
||||
* VIRTIO_NET_F_CTRL_MAC_ADDR feature is available.
|
||||
*/
|
||||
struct virtio_net_ctrl_mac {
|
||||
__virtio32 entries;
|
||||
uint8_t macs[][ETH_ALEN];
|
||||
} QEMU_PACKED;
|
||||
|
||||
#define VIRTIO_NET_CTRL_MAC 1
|
||||
#define VIRTIO_NET_CTRL_MAC_TABLE_SET 0
|
||||
#define VIRTIO_NET_CTRL_MAC_ADDR_SET 1
|
||||
|
||||
/*
|
||||
* Control VLAN filtering
|
||||
*
|
||||
* The VLAN filter table is controlled via a simple ADD/DEL interface.
|
||||
* VLAN IDs not added may be filterd by the hypervisor. Del is the
|
||||
* opposite of add. Both commands expect an out entry containing a 2
|
||||
* byte VLAN ID. VLAN filterting is available with the
|
||||
* VIRTIO_NET_F_CTRL_VLAN feature bit.
|
||||
*/
|
||||
#define VIRTIO_NET_CTRL_VLAN 2
|
||||
#define VIRTIO_NET_CTRL_VLAN_ADD 0
|
||||
#define VIRTIO_NET_CTRL_VLAN_DEL 1
|
||||
|
||||
/*
|
||||
* Control link announce acknowledgement
|
||||
*
|
||||
* The command VIRTIO_NET_CTRL_ANNOUNCE_ACK is used to indicate that
|
||||
* driver has recevied the notification; device would clear the
|
||||
* VIRTIO_NET_S_ANNOUNCE bit in the status field after it receives
|
||||
* this command.
|
||||
*/
|
||||
#define VIRTIO_NET_CTRL_ANNOUNCE 3
|
||||
#define VIRTIO_NET_CTRL_ANNOUNCE_ACK 0
|
||||
|
||||
/*
|
||||
* Control Receive Flow Steering
|
||||
*/
|
||||
#define VIRTIO_NET_CTRL_MQ 4
|
||||
/*
|
||||
* The command VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET
|
||||
* enables Receive Flow Steering, specifying the number of the transmit and
|
||||
* receive queues that will be used. After the command is consumed and acked by
|
||||
* the device, the device will not steer new packets on receive virtqueues
|
||||
* other than specified nor read from transmit virtqueues other than specified.
|
||||
* Accordingly, driver should not transmit new packets on virtqueues other than
|
||||
* specified.
|
||||
*/
|
||||
struct virtio_net_ctrl_mq {
|
||||
__virtio16 virtqueue_pairs;
|
||||
};
|
||||
|
||||
#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0
|
||||
#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1
|
||||
#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000
|
||||
|
||||
/*
|
||||
* The command VIRTIO_NET_CTRL_MQ_RSS_CONFIG has the same effect as
|
||||
* VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET does and additionally configures
|
||||
* the receive steering to use a hash calculated for incoming packet
|
||||
* to decide on receive virtqueue to place the packet. The command
|
||||
* also provides parameters to calculate a hash and receive virtqueue.
|
||||
*/
|
||||
struct virtio_net_rss_config {
|
||||
uint32_t hash_types;
|
||||
uint16_t indirection_table_mask;
|
||||
uint16_t unclassified_queue;
|
||||
uint16_t indirection_table[1/* + indirection_table_mask */];
|
||||
uint16_t max_tx_vq;
|
||||
uint8_t hash_key_length;
|
||||
uint8_t hash_key_data[/* hash_key_length */];
|
||||
};
|
||||
|
||||
struct virtio_net_rss_config_hdr {
|
||||
uint32_t hash_types;
|
||||
uint16_t indirection_table_mask;
|
||||
uint16_t unclassified_queue;
|
||||
uint16_t indirection_table[/* 1 + indirection_table_mask */];
|
||||
};
|
||||
|
||||
struct virtio_net_rss_config_trailer {
|
||||
uint16_t max_tx_vq;
|
||||
uint8_t hash_key_length;
|
||||
uint8_t hash_key_data[/* hash_key_length */];
|
||||
};
|
||||
|
||||
#define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1
|
||||
|
||||
/*
|
||||
* The command VIRTIO_NET_CTRL_MQ_HASH_CONFIG requests the device
|
||||
* to include in the virtio header of the packet the value of the
|
||||
* calculated hash and the report type of hash. It also provides
|
||||
* parameters for hash calculation. The command requires feature
|
||||
* VIRTIO_NET_F_HASH_REPORT to be negotiated to extend the
|
||||
* layout of virtio header as defined in virtio_net_hdr_v1_hash.
|
||||
*/
|
||||
struct virtio_net_hash_config {
|
||||
uint32_t hash_types;
|
||||
/* for compatibility with virtio_net_rss_config */
|
||||
uint16_t reserved[4];
|
||||
uint8_t hash_key_length;
|
||||
uint8_t hash_key_data[/* hash_key_length */];
|
||||
};
|
||||
|
||||
#define VIRTIO_NET_CTRL_MQ_HASH_CONFIG 2
|
||||
|
||||
/*
|
||||
* Control network offloads
|
||||
*
|
||||
* Reconfigures the network offloads that Guest can handle.
|
||||
*
|
||||
* Available with the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature bit.
|
||||
*
|
||||
* Command data format matches the feature bit mask exactly.
|
||||
*
|
||||
* See VIRTIO_NET_F_GUEST_* for the list of offloads
|
||||
* that can be enabled/disabled.
|
||||
*/
|
||||
#define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5
|
||||
#define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0
|
||||
|
||||
/*
|
||||
* Control notifications coalescing.
|
||||
*
|
||||
* Request the device to change the notifications coalescing parameters.
|
||||
*
|
||||
* Available with the VIRTIO_NET_F_NOTF_COAL feature bit.
|
||||
*/
|
||||
#define VIRTIO_NET_CTRL_NOTF_COAL 6
|
||||
/*
|
||||
* Set the tx-usecs/tx-max-packets parameters.
|
||||
*/
|
||||
struct virtio_net_ctrl_coal_tx {
|
||||
/* Maximum number of packets to send before a TX notification */
|
||||
uint32_t tx_max_packets;
|
||||
/* Maximum number of usecs to delay a TX notification */
|
||||
uint32_t tx_usecs;
|
||||
};
|
||||
|
||||
#define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0
|
||||
|
||||
/*
|
||||
* Set the rx-usecs/rx-max-packets parameters.
|
||||
*/
|
||||
struct virtio_net_ctrl_coal_rx {
|
||||
/* Maximum number of packets to receive before a RX notification */
|
||||
uint32_t rx_max_packets;
|
||||
/* Maximum number of usecs to delay a RX notification */
|
||||
uint32_t rx_usecs;
|
||||
};
|
||||
|
||||
#define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET 1
|
||||
#define VIRTIO_NET_CTRL_NOTF_COAL_VQ_SET 2
|
||||
#define VIRTIO_NET_CTRL_NOTF_COAL_VQ_GET 3
|
||||
|
||||
struct virtio_net_ctrl_coal {
|
||||
uint32_t max_packets;
|
||||
uint32_t max_usecs;
|
||||
};
|
||||
|
||||
struct virtio_net_ctrl_coal_vq {
|
||||
uint16_t vqn;
|
||||
uint16_t reserved;
|
||||
struct virtio_net_ctrl_coal coal;
|
||||
};
|
||||
|
||||
/*
|
||||
* Device Statistics
|
||||
*/
|
||||
#define VIRTIO_NET_CTRL_STATS 8
|
||||
#define VIRTIO_NET_CTRL_STATS_QUERY 0
|
||||
#define VIRTIO_NET_CTRL_STATS_GET 1
|
||||
|
||||
struct virtio_net_stats_capabilities {
|
||||
|
||||
#define VIRTIO_NET_STATS_TYPE_CVQ (1ULL << 32)
|
||||
|
||||
#define VIRTIO_NET_STATS_TYPE_RX_BASIC (1ULL << 0)
|
||||
#define VIRTIO_NET_STATS_TYPE_RX_CSUM (1ULL << 1)
|
||||
#define VIRTIO_NET_STATS_TYPE_RX_GSO (1ULL << 2)
|
||||
#define VIRTIO_NET_STATS_TYPE_RX_SPEED (1ULL << 3)
|
||||
|
||||
#define VIRTIO_NET_STATS_TYPE_TX_BASIC (1ULL << 16)
|
||||
#define VIRTIO_NET_STATS_TYPE_TX_CSUM (1ULL << 17)
|
||||
#define VIRTIO_NET_STATS_TYPE_TX_GSO (1ULL << 18)
|
||||
#define VIRTIO_NET_STATS_TYPE_TX_SPEED (1ULL << 19)
|
||||
|
||||
uint64_t supported_stats_types[1];
|
||||
};
|
||||
|
||||
struct virtio_net_ctrl_queue_stats {
|
||||
struct {
|
||||
uint16_t vq_index;
|
||||
uint16_t reserved[3];
|
||||
uint64_t types_bitmap[1];
|
||||
} stats[1];
|
||||
};
|
||||
|
||||
struct virtio_net_stats_reply_hdr {
|
||||
#define VIRTIO_NET_STATS_TYPE_REPLY_CVQ 32
|
||||
|
||||
#define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC 0
|
||||
#define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM 1
|
||||
#define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO 2
|
||||
#define VIRTIO_NET_STATS_TYPE_REPLY_RX_SPEED 3
|
||||
|
||||
#define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC 16
|
||||
#define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM 17
|
||||
#define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO 18
|
||||
#define VIRTIO_NET_STATS_TYPE_REPLY_TX_SPEED 19
|
||||
uint8_t type;
|
||||
uint8_t reserved;
|
||||
uint16_t vq_index;
|
||||
uint16_t reserved1;
|
||||
uint16_t size;
|
||||
};
|
||||
|
||||
struct virtio_net_stats_cvq {
|
||||
struct virtio_net_stats_reply_hdr hdr;
|
||||
|
||||
uint64_t command_num;
|
||||
uint64_t ok_num;
|
||||
};
|
||||
|
||||
struct virtio_net_stats_rx_basic {
|
||||
struct virtio_net_stats_reply_hdr hdr;
|
||||
|
||||
uint64_t rx_notifications;
|
||||
|
||||
uint64_t rx_packets;
|
||||
uint64_t rx_bytes;
|
||||
|
||||
uint64_t rx_interrupts;
|
||||
|
||||
uint64_t rx_drops;
|
||||
uint64_t rx_drop_overruns;
|
||||
};
|
||||
|
||||
struct virtio_net_stats_tx_basic {
|
||||
struct virtio_net_stats_reply_hdr hdr;
|
||||
|
||||
uint64_t tx_notifications;
|
||||
|
||||
uint64_t tx_packets;
|
||||
uint64_t tx_bytes;
|
||||
|
||||
uint64_t tx_interrupts;
|
||||
|
||||
uint64_t tx_drops;
|
||||
uint64_t tx_drop_malformed;
|
||||
};
|
||||
|
||||
struct virtio_net_stats_rx_csum {
|
||||
struct virtio_net_stats_reply_hdr hdr;
|
||||
|
||||
uint64_t rx_csum_valid;
|
||||
uint64_t rx_needs_csum;
|
||||
uint64_t rx_csum_none;
|
||||
uint64_t rx_csum_bad;
|
||||
};
|
||||
|
||||
struct virtio_net_stats_tx_csum {
|
||||
struct virtio_net_stats_reply_hdr hdr;
|
||||
|
||||
uint64_t tx_csum_none;
|
||||
uint64_t tx_needs_csum;
|
||||
};
|
||||
|
||||
struct virtio_net_stats_rx_gso {
|
||||
struct virtio_net_stats_reply_hdr hdr;
|
||||
|
||||
uint64_t rx_gso_packets;
|
||||
uint64_t rx_gso_bytes;
|
||||
uint64_t rx_gso_packets_coalesced;
|
||||
uint64_t rx_gso_bytes_coalesced;
|
||||
};
|
||||
|
||||
struct virtio_net_stats_tx_gso {
|
||||
struct virtio_net_stats_reply_hdr hdr;
|
||||
|
||||
uint64_t tx_gso_packets;
|
||||
uint64_t tx_gso_bytes;
|
||||
uint64_t tx_gso_segments;
|
||||
uint64_t tx_gso_segments_bytes;
|
||||
uint64_t tx_gso_packets_noseg;
|
||||
uint64_t tx_gso_bytes_noseg;
|
||||
};
|
||||
|
||||
struct virtio_net_stats_rx_speed {
|
||||
struct virtio_net_stats_reply_hdr hdr;
|
||||
|
||||
/* rx_{packets,bytes}_allowance_exceeded are too long. So rename to
|
||||
* short name.
|
||||
*/
|
||||
uint64_t rx_ratelimit_packets;
|
||||
uint64_t rx_ratelimit_bytes;
|
||||
};
|
||||
|
||||
struct virtio_net_stats_tx_speed {
|
||||
struct virtio_net_stats_reply_hdr hdr;
|
||||
|
||||
/* tx_{packets,bytes}_allowance_exceeded are too long. So rename to
|
||||
* short name.
|
||||
*/
|
||||
uint64_t tx_ratelimit_packets;
|
||||
uint64_t tx_ratelimit_bytes;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_VIRTIO_NET_H */
|
||||
@@ -0,0 +1,435 @@
|
||||
/*
|
||||
* Virtio PCI driver
|
||||
*
|
||||
* This module allows virtio devices to be used over a virtual PCI device.
|
||||
* This can be used with QEMU based VMMs like KVM or Xen.
|
||||
*
|
||||
* Copyright IBM Corp. 2007
|
||||
*
|
||||
* Authors:
|
||||
* Anthony Liguori <[email protected]>
|
||||
*
|
||||
* This header is BSD licensed so anyone can use the definitions to implement
|
||||
* compatible drivers/servers.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_VIRTIO_PCI_H
|
||||
#define _LINUX_VIRTIO_PCI_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
#include "standard-headers/linux/const.h"
|
||||
|
||||
#ifndef VIRTIO_PCI_NO_LEGACY
|
||||
|
||||
/* A 32-bit r/o bitmask of the features supported by the host */
|
||||
#define VIRTIO_PCI_HOST_FEATURES 0
|
||||
|
||||
/* A 32-bit r/w bitmask of features activated by the guest */
|
||||
#define VIRTIO_PCI_GUEST_FEATURES 4
|
||||
|
||||
/* A 32-bit r/w PFN for the currently selected queue */
|
||||
#define VIRTIO_PCI_QUEUE_PFN 8
|
||||
|
||||
/* A 16-bit r/o queue size for the currently selected queue */
|
||||
#define VIRTIO_PCI_QUEUE_NUM 12
|
||||
|
||||
/* A 16-bit r/w queue selector */
|
||||
#define VIRTIO_PCI_QUEUE_SEL 14
|
||||
|
||||
/* A 16-bit r/w queue notifier */
|
||||
#define VIRTIO_PCI_QUEUE_NOTIFY 16
|
||||
|
||||
/* An 8-bit device status register. */
|
||||
#define VIRTIO_PCI_STATUS 18
|
||||
|
||||
/* An 8-bit r/o interrupt status register. Reading the value will return the
|
||||
* current contents of the ISR and will also clear it. This is effectively
|
||||
* a read-and-acknowledge. */
|
||||
#define VIRTIO_PCI_ISR 19
|
||||
|
||||
/* MSI-X registers: only enabled if MSI-X is enabled. */
|
||||
/* A 16-bit vector for configuration changes. */
|
||||
#define VIRTIO_MSI_CONFIG_VECTOR 20
|
||||
/* A 16-bit vector for selected queue notifications. */
|
||||
#define VIRTIO_MSI_QUEUE_VECTOR 22
|
||||
|
||||
/* The remaining space is defined by each driver as the per-driver
|
||||
* configuration space */
|
||||
#define VIRTIO_PCI_CONFIG_OFF(msix_enabled) ((msix_enabled) ? 24 : 20)
|
||||
/* Deprecated: please use VIRTIO_PCI_CONFIG_OFF instead */
|
||||
#define VIRTIO_PCI_CONFIG(dev) VIRTIO_PCI_CONFIG_OFF((dev)->msix_enabled)
|
||||
|
||||
/* Virtio ABI version, this must match exactly */
|
||||
#define VIRTIO_PCI_ABI_VERSION 0
|
||||
|
||||
/* How many bits to shift physical queue address written to QUEUE_PFN.
|
||||
* 12 is historical, and due to x86 page size. */
|
||||
#define VIRTIO_PCI_QUEUE_ADDR_SHIFT 12
|
||||
|
||||
/* The alignment to use between consumer and producer parts of vring.
|
||||
* x86 pagesize again. */
|
||||
#define VIRTIO_PCI_VRING_ALIGN 4096
|
||||
|
||||
#endif /* VIRTIO_PCI_NO_LEGACY */
|
||||
|
||||
/* The bit of the ISR which indicates a device configuration change. */
|
||||
#define VIRTIO_PCI_ISR_CONFIG 0x2
|
||||
/* Vector value used to disable MSI for queue */
|
||||
#define VIRTIO_MSI_NO_VECTOR 0xffff
|
||||
|
||||
#ifndef VIRTIO_PCI_NO_MODERN
|
||||
|
||||
/* IDs for different capabilities. Must all exist. */
|
||||
|
||||
/* Common configuration */
|
||||
#define VIRTIO_PCI_CAP_COMMON_CFG 1
|
||||
/* Notifications */
|
||||
#define VIRTIO_PCI_CAP_NOTIFY_CFG 2
|
||||
/* ISR access */
|
||||
#define VIRTIO_PCI_CAP_ISR_CFG 3
|
||||
/* Device specific configuration */
|
||||
#define VIRTIO_PCI_CAP_DEVICE_CFG 4
|
||||
/* PCI configuration access */
|
||||
#define VIRTIO_PCI_CAP_PCI_CFG 5
|
||||
/* Additional shared memory capability */
|
||||
#define VIRTIO_PCI_CAP_SHARED_MEMORY_CFG 8
|
||||
/* PCI vendor data configuration */
|
||||
#define VIRTIO_PCI_CAP_VENDOR_CFG 9
|
||||
|
||||
/* This is the PCI capability header: */
|
||||
struct virtio_pci_cap {
|
||||
uint8_t cap_vndr; /* Generic PCI field: PCI_CAP_ID_VNDR */
|
||||
uint8_t cap_next; /* Generic PCI field: next ptr. */
|
||||
uint8_t cap_len; /* Generic PCI field: capability length */
|
||||
uint8_t cfg_type; /* Identifies the structure. */
|
||||
uint8_t bar; /* Where to find it. */
|
||||
uint8_t id; /* Multiple capabilities of the same type */
|
||||
uint8_t padding[2]; /* Pad to full dword. */
|
||||
uint32_t offset; /* Offset within bar. */
|
||||
uint32_t length; /* Length of the structure, in bytes. */
|
||||
};
|
||||
|
||||
/* This is the PCI vendor data capability header: */
|
||||
struct virtio_pci_vndr_data {
|
||||
uint8_t cap_vndr; /* Generic PCI field: PCI_CAP_ID_VNDR */
|
||||
uint8_t cap_next; /* Generic PCI field: next ptr. */
|
||||
uint8_t cap_len; /* Generic PCI field: capability length */
|
||||
uint8_t cfg_type; /* Identifies the structure. */
|
||||
uint16_t vendor_id; /* Identifies the vendor-specific format. */
|
||||
/* For Vendor Definition */
|
||||
/* Pads structure to a multiple of 4 bytes */
|
||||
/* Reads must not have side effects */
|
||||
};
|
||||
|
||||
struct virtio_pci_cap64 {
|
||||
struct virtio_pci_cap cap;
|
||||
uint32_t offset_hi; /* Most sig 32 bits of offset */
|
||||
uint32_t length_hi; /* Most sig 32 bits of length */
|
||||
};
|
||||
|
||||
struct virtio_pci_notify_cap {
|
||||
struct virtio_pci_cap cap;
|
||||
uint32_t notify_off_multiplier; /* Multiplier for queue_notify_off. */
|
||||
};
|
||||
|
||||
/* Fields in VIRTIO_PCI_CAP_COMMON_CFG: */
|
||||
struct virtio_pci_common_cfg {
|
||||
/* About the whole device. */
|
||||
uint32_t device_feature_select; /* read-write */
|
||||
uint32_t device_feature; /* read-only */
|
||||
uint32_t guest_feature_select; /* read-write */
|
||||
uint32_t guest_feature; /* read-write */
|
||||
uint16_t msix_config; /* read-write */
|
||||
uint16_t num_queues; /* read-only */
|
||||
uint8_t device_status; /* read-write */
|
||||
uint8_t config_generation; /* read-only */
|
||||
|
||||
/* About a specific virtqueue. */
|
||||
uint16_t queue_select; /* read-write */
|
||||
uint16_t queue_size; /* read-write, power of 2. */
|
||||
uint16_t queue_msix_vector; /* read-write */
|
||||
uint16_t queue_enable; /* read-write */
|
||||
uint16_t queue_notify_off; /* read-only */
|
||||
uint32_t queue_desc_lo; /* read-write */
|
||||
uint32_t queue_desc_hi; /* read-write */
|
||||
uint32_t queue_avail_lo; /* read-write */
|
||||
uint32_t queue_avail_hi; /* read-write */
|
||||
uint32_t queue_used_lo; /* read-write */
|
||||
uint32_t queue_used_hi; /* read-write */
|
||||
};
|
||||
|
||||
/*
|
||||
* Warning: do not use sizeof on this: use offsetofend for
|
||||
* specific fields you need.
|
||||
*/
|
||||
struct virtio_pci_modern_common_cfg {
|
||||
struct virtio_pci_common_cfg cfg;
|
||||
|
||||
uint16_t queue_notify_data; /* read-write */
|
||||
uint16_t queue_reset; /* read-write */
|
||||
|
||||
uint16_t admin_queue_index; /* read-only */
|
||||
uint16_t admin_queue_num; /* read-only */
|
||||
};
|
||||
|
||||
/* Fields in VIRTIO_PCI_CAP_PCI_CFG: */
|
||||
struct virtio_pci_cfg_cap {
|
||||
struct virtio_pci_cap cap;
|
||||
uint8_t pci_cfg_data[4]; /* Data for BAR access. */
|
||||
};
|
||||
|
||||
/* Macro versions of offsets for the Old Timers! */
|
||||
#define VIRTIO_PCI_CAP_VNDR 0
|
||||
#define VIRTIO_PCI_CAP_NEXT 1
|
||||
#define VIRTIO_PCI_CAP_LEN 2
|
||||
#define VIRTIO_PCI_CAP_CFG_TYPE 3
|
||||
#define VIRTIO_PCI_CAP_BAR 4
|
||||
#define VIRTIO_PCI_CAP_OFFSET 8
|
||||
#define VIRTIO_PCI_CAP_LENGTH 12
|
||||
|
||||
#define VIRTIO_PCI_NOTIFY_CAP_MULT 16
|
||||
|
||||
#define VIRTIO_PCI_COMMON_DFSELECT 0
|
||||
#define VIRTIO_PCI_COMMON_DF 4
|
||||
#define VIRTIO_PCI_COMMON_GFSELECT 8
|
||||
#define VIRTIO_PCI_COMMON_GF 12
|
||||
#define VIRTIO_PCI_COMMON_MSIX 16
|
||||
#define VIRTIO_PCI_COMMON_NUMQ 18
|
||||
#define VIRTIO_PCI_COMMON_STATUS 20
|
||||
#define VIRTIO_PCI_COMMON_CFGGENERATION 21
|
||||
#define VIRTIO_PCI_COMMON_Q_SELECT 22
|
||||
#define VIRTIO_PCI_COMMON_Q_SIZE 24
|
||||
#define VIRTIO_PCI_COMMON_Q_MSIX 26
|
||||
#define VIRTIO_PCI_COMMON_Q_ENABLE 28
|
||||
#define VIRTIO_PCI_COMMON_Q_NOFF 30
|
||||
#define VIRTIO_PCI_COMMON_Q_DESCLO 32
|
||||
#define VIRTIO_PCI_COMMON_Q_DESCHI 36
|
||||
#define VIRTIO_PCI_COMMON_Q_AVAILLO 40
|
||||
#define VIRTIO_PCI_COMMON_Q_AVAILHI 44
|
||||
#define VIRTIO_PCI_COMMON_Q_USEDLO 48
|
||||
#define VIRTIO_PCI_COMMON_Q_USEDHI 52
|
||||
#define VIRTIO_PCI_COMMON_Q_NDATA 56
|
||||
#define VIRTIO_PCI_COMMON_Q_RESET 58
|
||||
#define VIRTIO_PCI_COMMON_ADM_Q_IDX 60
|
||||
#define VIRTIO_PCI_COMMON_ADM_Q_NUM 62
|
||||
|
||||
#endif /* VIRTIO_PCI_NO_MODERN */
|
||||
|
||||
/* Admin command status. */
|
||||
#define VIRTIO_ADMIN_STATUS_OK 0
|
||||
|
||||
/* Admin command opcode. */
|
||||
#define VIRTIO_ADMIN_CMD_LIST_QUERY 0x0
|
||||
#define VIRTIO_ADMIN_CMD_LIST_USE 0x1
|
||||
|
||||
/* Admin command group type. */
|
||||
#define VIRTIO_ADMIN_GROUP_TYPE_SELF 0x0
|
||||
#define VIRTIO_ADMIN_GROUP_TYPE_SRIOV 0x1
|
||||
|
||||
/* Transitional device admin command. */
|
||||
#define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_WRITE 0x2
|
||||
#define VIRTIO_ADMIN_CMD_LEGACY_COMMON_CFG_READ 0x3
|
||||
#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_WRITE 0x4
|
||||
#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_READ 0x5
|
||||
#define VIRTIO_ADMIN_CMD_LEGACY_NOTIFY_INFO 0x6
|
||||
|
||||
/* Device parts access commands. */
|
||||
#define VIRTIO_ADMIN_CMD_CAP_ID_LIST_QUERY 0x7
|
||||
#define VIRTIO_ADMIN_CMD_DEVICE_CAP_GET 0x8
|
||||
#define VIRTIO_ADMIN_CMD_DRIVER_CAP_SET 0x9
|
||||
#define VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE 0xa
|
||||
#define VIRTIO_ADMIN_CMD_RESOURCE_OBJ_DESTROY 0xd
|
||||
#define VIRTIO_ADMIN_CMD_DEV_PARTS_METADATA_GET 0xe
|
||||
#define VIRTIO_ADMIN_CMD_DEV_PARTS_GET 0xf
|
||||
#define VIRTIO_ADMIN_CMD_DEV_PARTS_SET 0x10
|
||||
#define VIRTIO_ADMIN_CMD_DEV_MODE_SET 0x11
|
||||
|
||||
struct virtio_admin_cmd_hdr {
|
||||
uint16_t opcode;
|
||||
/*
|
||||
* 1 - SR-IOV
|
||||
* 2-65535 - reserved
|
||||
*/
|
||||
uint16_t group_type;
|
||||
/* Unused, reserved for future extensions. */
|
||||
uint8_t reserved1[12];
|
||||
uint64_t group_member_id;
|
||||
};
|
||||
|
||||
struct virtio_admin_cmd_status {
|
||||
uint16_t status;
|
||||
uint16_t status_qualifier;
|
||||
/* Unused, reserved for future extensions. */
|
||||
uint8_t reserved2[4];
|
||||
};
|
||||
|
||||
struct virtio_admin_cmd_legacy_wr_data {
|
||||
uint8_t offset; /* Starting offset of the register(s) to write. */
|
||||
uint8_t reserved[7];
|
||||
uint8_t registers[];
|
||||
};
|
||||
|
||||
struct virtio_admin_cmd_legacy_rd_data {
|
||||
uint8_t offset; /* Starting offset of the register(s) to read. */
|
||||
};
|
||||
|
||||
#define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_END 0
|
||||
#define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_OWNER_DEV 0x1
|
||||
#define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_OWNER_MEM 0x2
|
||||
|
||||
#define VIRTIO_ADMIN_CMD_MAX_NOTIFY_INFO 4
|
||||
|
||||
struct virtio_admin_cmd_notify_info_data {
|
||||
uint8_t flags; /* 0 = end of list, 1 = owner device, 2 = member device */
|
||||
uint8_t bar; /* BAR of the member or the owner device */
|
||||
uint8_t padding[6];
|
||||
uint64_t offset; /* Offset within bar. */
|
||||
};
|
||||
|
||||
struct virtio_admin_cmd_notify_info_result {
|
||||
struct virtio_admin_cmd_notify_info_data entries[VIRTIO_ADMIN_CMD_MAX_NOTIFY_INFO];
|
||||
};
|
||||
|
||||
#define VIRTIO_DEV_PARTS_CAP 0x0000
|
||||
|
||||
struct virtio_dev_parts_cap {
|
||||
uint8_t get_parts_resource_objects_limit;
|
||||
uint8_t set_parts_resource_objects_limit;
|
||||
};
|
||||
|
||||
#define MAX_CAP_ID __KERNEL_DIV_ROUND_UP(VIRTIO_DEV_PARTS_CAP + 1, 64)
|
||||
|
||||
struct virtio_admin_cmd_query_cap_id_result {
|
||||
uint64_t supported_caps[MAX_CAP_ID];
|
||||
};
|
||||
|
||||
struct virtio_admin_cmd_cap_get_data {
|
||||
uint16_t id;
|
||||
uint8_t reserved[6];
|
||||
};
|
||||
|
||||
struct virtio_admin_cmd_cap_set_data {
|
||||
uint16_t id;
|
||||
uint8_t reserved[6];
|
||||
uint8_t cap_specific_data[];
|
||||
};
|
||||
|
||||
struct virtio_admin_cmd_resource_obj_cmd_hdr {
|
||||
uint16_t type;
|
||||
uint8_t reserved[2];
|
||||
uint32_t id; /* Indicates unique resource object id per resource object type */
|
||||
};
|
||||
|
||||
struct virtio_admin_cmd_resource_obj_create_data {
|
||||
struct virtio_admin_cmd_resource_obj_cmd_hdr hdr;
|
||||
uint64_t flags;
|
||||
uint8_t resource_obj_specific_data[];
|
||||
};
|
||||
|
||||
#define VIRTIO_RESOURCE_OBJ_DEV_PARTS 0
|
||||
|
||||
#define VIRTIO_RESOURCE_OBJ_DEV_PARTS_TYPE_GET 0
|
||||
#define VIRTIO_RESOURCE_OBJ_DEV_PARTS_TYPE_SET 1
|
||||
|
||||
struct virtio_resource_obj_dev_parts {
|
||||
uint8_t type;
|
||||
uint8_t reserved[7];
|
||||
};
|
||||
|
||||
#define VIRTIO_ADMIN_CMD_DEV_PARTS_METADATA_TYPE_SIZE 0
|
||||
#define VIRTIO_ADMIN_CMD_DEV_PARTS_METADATA_TYPE_COUNT 1
|
||||
#define VIRTIO_ADMIN_CMD_DEV_PARTS_METADATA_TYPE_LIST 2
|
||||
|
||||
struct virtio_admin_cmd_dev_parts_metadata_data {
|
||||
struct virtio_admin_cmd_resource_obj_cmd_hdr hdr;
|
||||
uint8_t type;
|
||||
uint8_t reserved[7];
|
||||
};
|
||||
|
||||
#define VIRTIO_DEV_PART_F_OPTIONAL 0
|
||||
|
||||
struct virtio_dev_part_hdr {
|
||||
uint16_t part_type;
|
||||
uint8_t flags;
|
||||
uint8_t reserved;
|
||||
union {
|
||||
struct {
|
||||
uint32_t offset;
|
||||
uint32_t reserved;
|
||||
} pci_common_cfg;
|
||||
struct {
|
||||
uint16_t index;
|
||||
uint8_t reserved[6];
|
||||
} vq_index;
|
||||
} selector;
|
||||
uint32_t length;
|
||||
};
|
||||
|
||||
struct virtio_dev_part {
|
||||
struct virtio_dev_part_hdr hdr;
|
||||
uint8_t value[];
|
||||
};
|
||||
|
||||
struct virtio_admin_cmd_dev_parts_metadata_result {
|
||||
union {
|
||||
struct {
|
||||
uint32_t size;
|
||||
uint32_t reserved;
|
||||
} parts_size;
|
||||
struct {
|
||||
uint32_t count;
|
||||
uint32_t reserved;
|
||||
} hdr_list_count;
|
||||
struct {
|
||||
uint32_t count;
|
||||
uint32_t reserved;
|
||||
struct virtio_dev_part_hdr hdrs[];
|
||||
} hdr_list;
|
||||
};
|
||||
};
|
||||
|
||||
#define VIRTIO_ADMIN_CMD_DEV_PARTS_GET_TYPE_SELECTED 0
|
||||
#define VIRTIO_ADMIN_CMD_DEV_PARTS_GET_TYPE_ALL 1
|
||||
|
||||
struct virtio_admin_cmd_dev_parts_get_data {
|
||||
struct virtio_admin_cmd_resource_obj_cmd_hdr hdr;
|
||||
uint8_t type;
|
||||
uint8_t reserved[7];
|
||||
struct virtio_dev_part_hdr hdr_list[];
|
||||
};
|
||||
|
||||
struct virtio_admin_cmd_dev_parts_set_data {
|
||||
struct virtio_admin_cmd_resource_obj_cmd_hdr hdr;
|
||||
struct virtio_dev_part parts[];
|
||||
};
|
||||
|
||||
#define VIRTIO_ADMIN_CMD_DEV_MODE_F_STOPPED 0
|
||||
|
||||
struct virtio_admin_cmd_dev_mode_set_data {
|
||||
uint8_t flags;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
* Author: Johannes Berg <[email protected]>
|
||||
*/
|
||||
#ifndef _LINUX_VIRTIO_PCIDEV_H
|
||||
#define _LINUX_VIRTIO_PCIDEV_H
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
/**
|
||||
* enum virtio_pcidev_ops - virtual PCI device operations
|
||||
* @VIRTIO_PCIDEV_OP_RESERVED: reserved to catch errors
|
||||
* @VIRTIO_PCIDEV_OP_CFG_READ: read config space, size is 1, 2, 4 or 8;
|
||||
* the @data field should be filled in by the device (in little endian).
|
||||
* @VIRTIO_PCIDEV_OP_CFG_WRITE: write config space, size is 1, 2, 4 or 8;
|
||||
* the @data field contains the data to write (in little endian).
|
||||
* @VIRTIO_PCIDEV_OP_MMIO_READ: read BAR mem/pio, size can be variable;
|
||||
* the @data field should be filled in by the device (in little endian).
|
||||
* @VIRTIO_PCIDEV_OP_MMIO_WRITE: write BAR mem/pio, size can be variable;
|
||||
* the @data field contains the data to write (in little endian).
|
||||
* @VIRTIO_PCIDEV_OP_MMIO_MEMSET: memset MMIO, size is variable but
|
||||
* the @data field only has one byte (unlike @VIRTIO_PCIDEV_OP_MMIO_WRITE)
|
||||
* @VIRTIO_PCIDEV_OP_INT: legacy INTx# pin interrupt, the addr field is 1-4 for
|
||||
* the number
|
||||
* @VIRTIO_PCIDEV_OP_MSI: MSI(-X) interrupt, this message basically transports
|
||||
* the 16- or 32-bit write that would otherwise be done into memory,
|
||||
* analogous to the write messages (@VIRTIO_PCIDEV_OP_MMIO_WRITE) above
|
||||
* @VIRTIO_PCIDEV_OP_PME: Dummy message whose content is ignored (and should be
|
||||
* all zeroes) to signal the PME# pin.
|
||||
*/
|
||||
enum virtio_pcidev_ops {
|
||||
VIRTIO_PCIDEV_OP_RESERVED = 0,
|
||||
VIRTIO_PCIDEV_OP_CFG_READ,
|
||||
VIRTIO_PCIDEV_OP_CFG_WRITE,
|
||||
VIRTIO_PCIDEV_OP_MMIO_READ,
|
||||
VIRTIO_PCIDEV_OP_MMIO_WRITE,
|
||||
VIRTIO_PCIDEV_OP_MMIO_MEMSET,
|
||||
VIRTIO_PCIDEV_OP_INT,
|
||||
VIRTIO_PCIDEV_OP_MSI,
|
||||
VIRTIO_PCIDEV_OP_PME,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct virtio_pcidev_msg - virtio PCI device operation
|
||||
* @op: the operation to do
|
||||
* @bar: the bar (only with BAR read/write messages)
|
||||
* @reserved: reserved
|
||||
* @size: the size of the read/write (in bytes)
|
||||
* @addr: the address to read/write
|
||||
* @data: the data, normally @size long, but just one byte for
|
||||
* %VIRTIO_PCIDEV_OP_MMIO_MEMSET
|
||||
*
|
||||
* Note: the fields are all in native (CPU) endian, however, the
|
||||
* @data values will often be in little endian (see the ops above.)
|
||||
*/
|
||||
struct virtio_pcidev_msg {
|
||||
uint8_t op;
|
||||
uint8_t bar;
|
||||
uint16_t reserved;
|
||||
uint32_t size;
|
||||
uint64_t addr;
|
||||
uint8_t data[];
|
||||
};
|
||||
|
||||
#endif /* _LINUX_VIRTIO_PCIDEV_H */
|
||||
@@ -0,0 +1,41 @@
|
||||
/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause */
|
||||
/*
|
||||
* Definitions for virtio-pmem devices.
|
||||
*
|
||||
* Copyright (C) 2019 Red Hat, Inc.
|
||||
*
|
||||
* Author(s): Pankaj Gupta <[email protected]>
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_VIRTIO_PMEM_H
|
||||
#define _LINUX_VIRTIO_PMEM_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
|
||||
/* Feature bits */
|
||||
/* guest physical address range will be indicated as shared memory region 0 */
|
||||
#define VIRTIO_PMEM_F_SHMEM_REGION 0
|
||||
|
||||
/* shmid of the shared memory region corresponding to the pmem */
|
||||
#define VIRTIO_PMEM_SHMEM_REGION_ID 0
|
||||
|
||||
struct virtio_pmem_config {
|
||||
uint64_t start;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
#define VIRTIO_PMEM_REQ_TYPE_FLUSH 0
|
||||
|
||||
struct virtio_pmem_resp {
|
||||
/* Host return status corresponding to flush request */
|
||||
uint32_t ret;
|
||||
};
|
||||
|
||||
struct virtio_pmem_req {
|
||||
/* command type */
|
||||
uint32_t type;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,249 @@
|
||||
#ifndef _LINUX_VIRTIO_RING_H
|
||||
#define _LINUX_VIRTIO_RING_H
|
||||
|
||||
#define VIRTIO_RING_NO_LEGACY
|
||||
/* An interface for efficient virtio implementation, currently for use by KVM,
|
||||
* but hopefully others soon. Do NOT change this since it will
|
||||
* break existing servers and clients.
|
||||
*
|
||||
* This header is BSD licensed so anyone can use the definitions to implement
|
||||
* compatible drivers/servers.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Copyright Rusty Russell IBM Corporation 2007. */
|
||||
#include "standard-headers/linux/types.h"
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
|
||||
/* This marks a buffer as continuing via the next field. */
|
||||
#define VRING_DESC_F_NEXT 1
|
||||
/* This marks a buffer as write-only (otherwise read-only). */
|
||||
#define VRING_DESC_F_WRITE 2
|
||||
/* This means the buffer contains a list of buffer descriptors. */
|
||||
#define VRING_DESC_F_INDIRECT 4
|
||||
|
||||
/*
|
||||
* Mark a descriptor as available or used in packed ring.
|
||||
* Notice: they are defined as shifts instead of shifted values.
|
||||
*/
|
||||
#define VRING_PACKED_DESC_F_AVAIL 7
|
||||
#define VRING_PACKED_DESC_F_USED 15
|
||||
|
||||
/* The Host uses this in used->flags to advise the Guest: don't kick me when
|
||||
* you add a buffer. It's unreliable, so it's simply an optimization. Guest
|
||||
* will still kick if it's out of buffers. */
|
||||
#define VRING_USED_F_NO_NOTIFY 1
|
||||
/* The Guest uses this in avail->flags to advise the Host: don't interrupt me
|
||||
* when you consume a buffer. It's unreliable, so it's simply an
|
||||
* optimization. */
|
||||
#define VRING_AVAIL_F_NO_INTERRUPT 1
|
||||
|
||||
/* Enable events in packed ring. */
|
||||
#define VRING_PACKED_EVENT_FLAG_ENABLE 0x0
|
||||
/* Disable events in packed ring. */
|
||||
#define VRING_PACKED_EVENT_FLAG_DISABLE 0x1
|
||||
/*
|
||||
* Enable events for a specific descriptor in packed ring.
|
||||
* (as specified by Descriptor Ring Change Event Offset/Wrap Counter).
|
||||
* Only valid if VIRTIO_RING_F_EVENT_IDX has been negotiated.
|
||||
*/
|
||||
#define VRING_PACKED_EVENT_FLAG_DESC 0x2
|
||||
|
||||
/*
|
||||
* Wrap counter bit shift in event suppression structure
|
||||
* of packed ring.
|
||||
*/
|
||||
#define VRING_PACKED_EVENT_F_WRAP_CTR 15
|
||||
|
||||
/* We support indirect buffer descriptors */
|
||||
#define VIRTIO_RING_F_INDIRECT_DESC 28
|
||||
|
||||
/* The Guest publishes the used index for which it expects an interrupt
|
||||
* at the end of the avail ring. Host should ignore the avail->flags field. */
|
||||
/* The Host publishes the avail index for which it expects a kick
|
||||
* at the end of the used ring. Guest should ignore the used->flags field. */
|
||||
#define VIRTIO_RING_F_EVENT_IDX 29
|
||||
|
||||
/* Alignment requirements for vring elements.
|
||||
* When using pre-virtio 1.0 layout, these fall out naturally.
|
||||
*/
|
||||
#define VRING_AVAIL_ALIGN_SIZE 2
|
||||
#define VRING_USED_ALIGN_SIZE 4
|
||||
#define VRING_DESC_ALIGN_SIZE 16
|
||||
|
||||
/**
|
||||
* struct vring_desc - Virtio ring descriptors,
|
||||
* 16 bytes long. These can chain together via @next.
|
||||
*
|
||||
* @addr: buffer address (guest-physical)
|
||||
* @len: buffer length
|
||||
* @flags: descriptor flags
|
||||
* @next: index of the next descriptor in the chain,
|
||||
* if the VRING_DESC_F_NEXT flag is set. We chain unused
|
||||
* descriptors via this, too.
|
||||
*/
|
||||
struct vring_desc {
|
||||
__virtio64 addr;
|
||||
__virtio32 len;
|
||||
__virtio16 flags;
|
||||
__virtio16 next;
|
||||
};
|
||||
|
||||
struct vring_avail {
|
||||
__virtio16 flags;
|
||||
__virtio16 idx;
|
||||
__virtio16 ring[];
|
||||
};
|
||||
|
||||
/* uint32_t is used here for ids for padding reasons. */
|
||||
struct vring_used_elem {
|
||||
/* Index of start of used descriptor chain. */
|
||||
__virtio32 id;
|
||||
/* Total length of the descriptor chain which was used (written to) */
|
||||
__virtio32 len;
|
||||
};
|
||||
|
||||
typedef struct vring_used_elem __attribute__((aligned(VRING_USED_ALIGN_SIZE)))
|
||||
vring_used_elem_t;
|
||||
|
||||
struct vring_used {
|
||||
__virtio16 flags;
|
||||
__virtio16 idx;
|
||||
vring_used_elem_t ring[];
|
||||
};
|
||||
|
||||
/*
|
||||
* The ring element addresses are passed between components with different
|
||||
* alignments assumptions. Thus, we might need to decrease the compiler-selected
|
||||
* alignment, and so must use a typedef to make sure the aligned attribute
|
||||
* actually takes hold:
|
||||
*
|
||||
* https://gcc.gnu.org/onlinedocs//gcc/Common-Type-Attributes.html#Common-Type-Attributes
|
||||
*
|
||||
* When used on a struct, or struct member, the aligned attribute can only
|
||||
* increase the alignment; in order to decrease it, the packed attribute must
|
||||
* be specified as well. When used as part of a typedef, the aligned attribute
|
||||
* can both increase and decrease alignment, and specifying the packed
|
||||
* attribute generates a warning.
|
||||
*/
|
||||
typedef struct vring_desc __attribute__((aligned(VRING_DESC_ALIGN_SIZE)))
|
||||
vring_desc_t;
|
||||
typedef struct vring_avail __attribute__((aligned(VRING_AVAIL_ALIGN_SIZE)))
|
||||
vring_avail_t;
|
||||
typedef struct vring_used __attribute__((aligned(VRING_USED_ALIGN_SIZE)))
|
||||
vring_used_t;
|
||||
|
||||
struct vring {
|
||||
unsigned int num;
|
||||
|
||||
vring_desc_t *desc;
|
||||
|
||||
vring_avail_t *avail;
|
||||
|
||||
vring_used_t *used;
|
||||
};
|
||||
|
||||
#ifndef VIRTIO_RING_NO_LEGACY
|
||||
|
||||
/* The standard layout for the ring is a continuous chunk of memory which looks
|
||||
* like this. We assume num is a power of 2.
|
||||
*
|
||||
* struct vring
|
||||
* {
|
||||
* // The actual descriptors (16 bytes each)
|
||||
* struct vring_desc desc[num];
|
||||
*
|
||||
* // A ring of available descriptor heads with free-running index.
|
||||
* __virtio16 avail_flags;
|
||||
* __virtio16 avail_idx;
|
||||
* __virtio16 available[num];
|
||||
* __virtio16 used_event_idx;
|
||||
*
|
||||
* // Padding to the next align boundary.
|
||||
* char pad[];
|
||||
*
|
||||
* // A ring of used descriptor heads with free-running index.
|
||||
* __virtio16 used_flags;
|
||||
* __virtio16 used_idx;
|
||||
* struct vring_used_elem used[num];
|
||||
* __virtio16 avail_event_idx;
|
||||
* };
|
||||
*/
|
||||
/* We publish the used event index at the end of the available ring, and vice
|
||||
* versa. They are at the end for backwards compatibility. */
|
||||
#define vring_used_event(vr) ((vr)->avail->ring[(vr)->num])
|
||||
#define vring_avail_event(vr) (*(__virtio16 *)&(vr)->used->ring[(vr)->num])
|
||||
|
||||
static inline void vring_init(struct vring *vr, unsigned int num, void *p,
|
||||
unsigned long align)
|
||||
{
|
||||
vr->num = num;
|
||||
vr->desc = p;
|
||||
vr->avail = (struct vring_avail *)((char *)p + num * sizeof(struct vring_desc));
|
||||
vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(__virtio16)
|
||||
+ align-1) & ~(align - 1));
|
||||
}
|
||||
|
||||
static inline unsigned vring_size(unsigned int num, unsigned long align)
|
||||
{
|
||||
return ((sizeof(struct vring_desc) * num + sizeof(__virtio16) * (3 + num)
|
||||
+ align - 1) & ~(align - 1))
|
||||
+ sizeof(__virtio16) * 3 + sizeof(struct vring_used_elem) * num;
|
||||
}
|
||||
|
||||
#endif /* VIRTIO_RING_NO_LEGACY */
|
||||
|
||||
/* The following is used with USED_EVENT_IDX and AVAIL_EVENT_IDX */
|
||||
/* Assuming a given event_idx value from the other side, if
|
||||
* we have just incremented index from old to new_idx,
|
||||
* should we trigger an event? */
|
||||
static inline int vring_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old)
|
||||
{
|
||||
/* Note: Xen has similar logic for notification hold-off
|
||||
* in include/xen/interface/io/ring.h with req_event and req_prod
|
||||
* corresponding to event_idx + 1 and new_idx respectively.
|
||||
* Note also that req_event and req_prod in Xen start at 1,
|
||||
* event indexes in virtio start at 0. */
|
||||
return (uint16_t)(new_idx - event_idx - 1) < (uint16_t)(new_idx - old);
|
||||
}
|
||||
|
||||
struct vring_packed_desc_event {
|
||||
/* Descriptor Ring Change Event Offset/Wrap Counter. */
|
||||
uint16_t off_wrap;
|
||||
/* Descriptor Ring Change Event Flags. */
|
||||
uint16_t flags;
|
||||
};
|
||||
|
||||
struct vring_packed_desc {
|
||||
/* Buffer Address. */
|
||||
uint64_t addr;
|
||||
/* Buffer Length. */
|
||||
uint32_t len;
|
||||
/* Buffer ID. */
|
||||
uint16_t id;
|
||||
/* The flags depending on descriptor type. */
|
||||
uint16_t flags;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_VIRTIO_RING_H */
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef _LINUX_VIRTIO_RNG_H
|
||||
#define _LINUX_VIRTIO_RNG_H
|
||||
/* This header is BSD licensed so anyone can use the definitions to implement
|
||||
* compatible drivers/servers. */
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
|
||||
#endif /* _LINUX_VIRTIO_RNG_H */
|
||||
@@ -0,0 +1,237 @@
|
||||
/* SPDX-License-Identifier: ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) */
|
||||
/*
|
||||
* Copyright (C) 2022-2024 OpenSynergy GmbH
|
||||
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_VIRTIO_RTC_H
|
||||
#define _LINUX_VIRTIO_RTC_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
/* alarm feature */
|
||||
#define VIRTIO_RTC_F_ALARM 0
|
||||
|
||||
/* read request message types */
|
||||
|
||||
#define VIRTIO_RTC_REQ_READ 0x0001
|
||||
#define VIRTIO_RTC_REQ_READ_CROSS 0x0002
|
||||
|
||||
/* control request message types */
|
||||
|
||||
#define VIRTIO_RTC_REQ_CFG 0x1000
|
||||
#define VIRTIO_RTC_REQ_CLOCK_CAP 0x1001
|
||||
#define VIRTIO_RTC_REQ_CROSS_CAP 0x1002
|
||||
#define VIRTIO_RTC_REQ_READ_ALARM 0x1003
|
||||
#define VIRTIO_RTC_REQ_SET_ALARM 0x1004
|
||||
#define VIRTIO_RTC_REQ_SET_ALARM_ENABLED 0x1005
|
||||
|
||||
/* alarmq message types */
|
||||
|
||||
#define VIRTIO_RTC_NOTIF_ALARM 0x2000
|
||||
|
||||
/* Message headers */
|
||||
|
||||
/** common request header */
|
||||
struct virtio_rtc_req_head {
|
||||
uint16_t msg_type;
|
||||
uint8_t reserved[6];
|
||||
};
|
||||
|
||||
/** common response header */
|
||||
struct virtio_rtc_resp_head {
|
||||
#define VIRTIO_RTC_S_OK 0
|
||||
#define VIRTIO_RTC_S_EOPNOTSUPP 2
|
||||
#define VIRTIO_RTC_S_ENODEV 3
|
||||
#define VIRTIO_RTC_S_EINVAL 4
|
||||
#define VIRTIO_RTC_S_EIO 5
|
||||
uint8_t status;
|
||||
uint8_t reserved[7];
|
||||
};
|
||||
|
||||
/** common notification header */
|
||||
struct virtio_rtc_notif_head {
|
||||
uint16_t msg_type;
|
||||
uint8_t reserved[6];
|
||||
};
|
||||
|
||||
/* read requests */
|
||||
|
||||
/* VIRTIO_RTC_REQ_READ message */
|
||||
|
||||
struct virtio_rtc_req_read {
|
||||
struct virtio_rtc_req_head head;
|
||||
uint16_t clock_id;
|
||||
uint8_t reserved[6];
|
||||
};
|
||||
|
||||
struct virtio_rtc_resp_read {
|
||||
struct virtio_rtc_resp_head head;
|
||||
uint64_t clock_reading;
|
||||
};
|
||||
|
||||
/* VIRTIO_RTC_REQ_READ_CROSS message */
|
||||
|
||||
struct virtio_rtc_req_read_cross {
|
||||
struct virtio_rtc_req_head head;
|
||||
uint16_t clock_id;
|
||||
/* Arm Generic Timer Counter-timer Virtual Count Register (CNTVCT_EL0) */
|
||||
#define VIRTIO_RTC_COUNTER_ARM_VCT 0
|
||||
/* x86 Time-Stamp Counter */
|
||||
#define VIRTIO_RTC_COUNTER_X86_TSC 1
|
||||
/* Invalid */
|
||||
#define VIRTIO_RTC_COUNTER_INVALID 0xFF
|
||||
uint8_t hw_counter;
|
||||
uint8_t reserved[5];
|
||||
};
|
||||
|
||||
struct virtio_rtc_resp_read_cross {
|
||||
struct virtio_rtc_resp_head head;
|
||||
uint64_t clock_reading;
|
||||
uint64_t counter_cycles;
|
||||
};
|
||||
|
||||
/* control requests */
|
||||
|
||||
/* VIRTIO_RTC_REQ_CFG message */
|
||||
|
||||
struct virtio_rtc_req_cfg {
|
||||
struct virtio_rtc_req_head head;
|
||||
/* no request params */
|
||||
};
|
||||
|
||||
struct virtio_rtc_resp_cfg {
|
||||
struct virtio_rtc_resp_head head;
|
||||
/** # of clocks -> clock ids < num_clocks are valid */
|
||||
uint16_t num_clocks;
|
||||
uint8_t reserved[6];
|
||||
};
|
||||
|
||||
/* VIRTIO_RTC_REQ_CLOCK_CAP message */
|
||||
|
||||
struct virtio_rtc_req_clock_cap {
|
||||
struct virtio_rtc_req_head head;
|
||||
uint16_t clock_id;
|
||||
uint8_t reserved[6];
|
||||
};
|
||||
|
||||
struct virtio_rtc_resp_clock_cap {
|
||||
struct virtio_rtc_resp_head head;
|
||||
#define VIRTIO_RTC_CLOCK_UTC 0
|
||||
#define VIRTIO_RTC_CLOCK_TAI 1
|
||||
#define VIRTIO_RTC_CLOCK_MONOTONIC 2
|
||||
#define VIRTIO_RTC_CLOCK_UTC_SMEARED 3
|
||||
#define VIRTIO_RTC_CLOCK_UTC_MAYBE_SMEARED 4
|
||||
uint8_t type;
|
||||
#define VIRTIO_RTC_SMEAR_UNSPECIFIED 0
|
||||
#define VIRTIO_RTC_SMEAR_NOON_LINEAR 1
|
||||
#define VIRTIO_RTC_SMEAR_UTC_SLS 2
|
||||
uint8_t leap_second_smearing;
|
||||
#define VIRTIO_RTC_FLAG_ALARM_CAP (1 << 0)
|
||||
uint8_t flags;
|
||||
uint8_t reserved[5];
|
||||
};
|
||||
|
||||
/* VIRTIO_RTC_REQ_CROSS_CAP message */
|
||||
|
||||
struct virtio_rtc_req_cross_cap {
|
||||
struct virtio_rtc_req_head head;
|
||||
uint16_t clock_id;
|
||||
uint8_t hw_counter;
|
||||
uint8_t reserved[5];
|
||||
};
|
||||
|
||||
struct virtio_rtc_resp_cross_cap {
|
||||
struct virtio_rtc_resp_head head;
|
||||
#define VIRTIO_RTC_FLAG_CROSS_CAP (1 << 0)
|
||||
uint8_t flags;
|
||||
uint8_t reserved[7];
|
||||
};
|
||||
|
||||
/* VIRTIO_RTC_REQ_READ_ALARM message */
|
||||
|
||||
struct virtio_rtc_req_read_alarm {
|
||||
struct virtio_rtc_req_head head;
|
||||
uint16_t clock_id;
|
||||
uint8_t reserved[6];
|
||||
};
|
||||
|
||||
struct virtio_rtc_resp_read_alarm {
|
||||
struct virtio_rtc_resp_head head;
|
||||
uint64_t alarm_time;
|
||||
#define VIRTIO_RTC_FLAG_ALARM_ENABLED (1 << 0)
|
||||
uint8_t flags;
|
||||
uint8_t reserved[7];
|
||||
};
|
||||
|
||||
/* VIRTIO_RTC_REQ_SET_ALARM message */
|
||||
|
||||
struct virtio_rtc_req_set_alarm {
|
||||
struct virtio_rtc_req_head head;
|
||||
uint64_t alarm_time;
|
||||
uint16_t clock_id;
|
||||
/* flag VIRTIO_RTC_FLAG_ALARM_ENABLED */
|
||||
uint8_t flags;
|
||||
uint8_t reserved[5];
|
||||
};
|
||||
|
||||
struct virtio_rtc_resp_set_alarm {
|
||||
struct virtio_rtc_resp_head head;
|
||||
/* no response params */
|
||||
};
|
||||
|
||||
/* VIRTIO_RTC_REQ_SET_ALARM_ENABLED message */
|
||||
|
||||
struct virtio_rtc_req_set_alarm_enabled {
|
||||
struct virtio_rtc_req_head head;
|
||||
uint16_t clock_id;
|
||||
/* flag VIRTIO_RTC_ALARM_ENABLED */
|
||||
uint8_t flags;
|
||||
uint8_t reserved[5];
|
||||
};
|
||||
|
||||
struct virtio_rtc_resp_set_alarm_enabled {
|
||||
struct virtio_rtc_resp_head head;
|
||||
/* no response params */
|
||||
};
|
||||
|
||||
/** Union of request types for requestq */
|
||||
union virtio_rtc_req_requestq {
|
||||
struct virtio_rtc_req_read read;
|
||||
struct virtio_rtc_req_read_cross read_cross;
|
||||
struct virtio_rtc_req_cfg cfg;
|
||||
struct virtio_rtc_req_clock_cap clock_cap;
|
||||
struct virtio_rtc_req_cross_cap cross_cap;
|
||||
struct virtio_rtc_req_read_alarm read_alarm;
|
||||
struct virtio_rtc_req_set_alarm set_alarm;
|
||||
struct virtio_rtc_req_set_alarm_enabled set_alarm_enabled;
|
||||
};
|
||||
|
||||
/** Union of response types for requestq */
|
||||
union virtio_rtc_resp_requestq {
|
||||
struct virtio_rtc_resp_read read;
|
||||
struct virtio_rtc_resp_read_cross read_cross;
|
||||
struct virtio_rtc_resp_cfg cfg;
|
||||
struct virtio_rtc_resp_clock_cap clock_cap;
|
||||
struct virtio_rtc_resp_cross_cap cross_cap;
|
||||
struct virtio_rtc_resp_read_alarm read_alarm;
|
||||
struct virtio_rtc_resp_set_alarm set_alarm;
|
||||
struct virtio_rtc_resp_set_alarm_enabled set_alarm_enabled;
|
||||
};
|
||||
|
||||
/* alarmq notifications */
|
||||
|
||||
/* VIRTIO_RTC_NOTIF_ALARM notification */
|
||||
|
||||
struct virtio_rtc_notif_alarm {
|
||||
struct virtio_rtc_notif_head head;
|
||||
uint16_t clock_id;
|
||||
uint8_t reserved[6];
|
||||
};
|
||||
|
||||
/** Union of notification types for alarmq */
|
||||
union virtio_rtc_notif_alarmq {
|
||||
struct virtio_rtc_notif_alarm alarm;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_VIRTIO_RTC_H */
|
||||
@@ -0,0 +1,24 @@
|
||||
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
|
||||
/*
|
||||
* Copyright (C) 2020-2021 OpenSynergy GmbH
|
||||
* Copyright (C) 2021 ARM Ltd.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_VIRTIO_SCMI_H
|
||||
#define _LINUX_VIRTIO_SCMI_H
|
||||
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
|
||||
/* Device implements some SCMI notifications, or delayed responses. */
|
||||
#define VIRTIO_SCMI_F_P2A_CHANNELS 0
|
||||
|
||||
/* Device implements any SCMI statistics shared memory region */
|
||||
#define VIRTIO_SCMI_F_SHARED_MEMORY 1
|
||||
|
||||
/* Virtqueues */
|
||||
|
||||
#define VIRTIO_SCMI_VQ_TX 0 /* cmdq */
|
||||
#define VIRTIO_SCMI_VQ_RX 1 /* eventq */
|
||||
#define VIRTIO_SCMI_VQ_MAX_CNT 2
|
||||
|
||||
#endif /* _LINUX_VIRTIO_SCMI_H */
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* This header is BSD licensed so anyone can use the definitions to implement
|
||||
* compatible drivers/servers.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_VIRTIO_SCSI_H
|
||||
#define _LINUX_VIRTIO_SCSI_H
|
||||
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
|
||||
/* Default values of the CDB and sense data size configuration fields */
|
||||
#define VIRTIO_SCSI_CDB_DEFAULT_SIZE 32
|
||||
#define VIRTIO_SCSI_SENSE_DEFAULT_SIZE 96
|
||||
|
||||
#ifndef VIRTIO_SCSI_CDB_SIZE
|
||||
#define VIRTIO_SCSI_CDB_SIZE VIRTIO_SCSI_CDB_DEFAULT_SIZE
|
||||
#endif
|
||||
#ifndef VIRTIO_SCSI_SENSE_SIZE
|
||||
#define VIRTIO_SCSI_SENSE_SIZE VIRTIO_SCSI_SENSE_DEFAULT_SIZE
|
||||
#endif
|
||||
|
||||
/* SCSI command request, followed by data-out */
|
||||
struct virtio_scsi_cmd_req {
|
||||
uint8_t lun[8]; /* Logical Unit Number */
|
||||
__virtio64 tag; /* Command identifier */
|
||||
uint8_t task_attr; /* Task attribute */
|
||||
uint8_t prio; /* SAM command priority field */
|
||||
uint8_t crn;
|
||||
uint8_t cdb[VIRTIO_SCSI_CDB_SIZE];
|
||||
} QEMU_PACKED;
|
||||
|
||||
/* SCSI command request, followed by protection information */
|
||||
struct virtio_scsi_cmd_req_pi {
|
||||
uint8_t lun[8]; /* Logical Unit Number */
|
||||
__virtio64 tag; /* Command identifier */
|
||||
uint8_t task_attr; /* Task attribute */
|
||||
uint8_t prio; /* SAM command priority field */
|
||||
uint8_t crn;
|
||||
__virtio32 pi_bytesout; /* DataOUT PI Number of bytes */
|
||||
__virtio32 pi_bytesin; /* DataIN PI Number of bytes */
|
||||
uint8_t cdb[VIRTIO_SCSI_CDB_SIZE];
|
||||
} QEMU_PACKED;
|
||||
|
||||
/* Response, followed by sense data and data-in */
|
||||
struct virtio_scsi_cmd_resp {
|
||||
__virtio32 sense_len; /* Sense data length */
|
||||
__virtio32 resid; /* Residual bytes in data buffer */
|
||||
__virtio16 status_qualifier; /* Status qualifier */
|
||||
uint8_t status; /* Command completion status */
|
||||
uint8_t response; /* Response values */
|
||||
uint8_t sense[VIRTIO_SCSI_SENSE_SIZE];
|
||||
} QEMU_PACKED;
|
||||
|
||||
/* Task Management Request */
|
||||
struct virtio_scsi_ctrl_tmf_req {
|
||||
__virtio32 type;
|
||||
__virtio32 subtype;
|
||||
uint8_t lun[8];
|
||||
__virtio64 tag;
|
||||
} QEMU_PACKED;
|
||||
|
||||
struct virtio_scsi_ctrl_tmf_resp {
|
||||
uint8_t response;
|
||||
} QEMU_PACKED;
|
||||
|
||||
/* Asynchronous notification query/subscription */
|
||||
struct virtio_scsi_ctrl_an_req {
|
||||
__virtio32 type;
|
||||
uint8_t lun[8];
|
||||
__virtio32 event_requested;
|
||||
} QEMU_PACKED;
|
||||
|
||||
struct virtio_scsi_ctrl_an_resp {
|
||||
__virtio32 event_actual;
|
||||
uint8_t response;
|
||||
} QEMU_PACKED;
|
||||
|
||||
struct virtio_scsi_event {
|
||||
__virtio32 event;
|
||||
uint8_t lun[8];
|
||||
__virtio32 reason;
|
||||
} QEMU_PACKED;
|
||||
|
||||
struct virtio_scsi_config {
|
||||
__virtio32 num_queues;
|
||||
__virtio32 seg_max;
|
||||
__virtio32 max_sectors;
|
||||
__virtio32 cmd_per_lun;
|
||||
__virtio32 event_info_size;
|
||||
__virtio32 sense_size;
|
||||
__virtio32 cdb_size;
|
||||
__virtio16 max_channel;
|
||||
__virtio16 max_target;
|
||||
__virtio32 max_lun;
|
||||
} QEMU_PACKED;
|
||||
|
||||
/* Feature Bits */
|
||||
#define VIRTIO_SCSI_F_INOUT 0
|
||||
#define VIRTIO_SCSI_F_HOTPLUG 1
|
||||
#define VIRTIO_SCSI_F_CHANGE 2
|
||||
#define VIRTIO_SCSI_F_T10_PI 3
|
||||
|
||||
/* Response codes */
|
||||
#define VIRTIO_SCSI_S_OK 0
|
||||
#define VIRTIO_SCSI_S_OVERRUN 1
|
||||
#define VIRTIO_SCSI_S_ABORTED 2
|
||||
#define VIRTIO_SCSI_S_BAD_TARGET 3
|
||||
#define VIRTIO_SCSI_S_RESET 4
|
||||
#define VIRTIO_SCSI_S_BUSY 5
|
||||
#define VIRTIO_SCSI_S_TRANSPORT_FAILURE 6
|
||||
#define VIRTIO_SCSI_S_TARGET_FAILURE 7
|
||||
#define VIRTIO_SCSI_S_NEXUS_FAILURE 8
|
||||
#define VIRTIO_SCSI_S_FAILURE 9
|
||||
#define VIRTIO_SCSI_S_FUNCTION_SUCCEEDED 10
|
||||
#define VIRTIO_SCSI_S_FUNCTION_REJECTED 11
|
||||
#define VIRTIO_SCSI_S_INCORRECT_LUN 12
|
||||
|
||||
/* Controlq type codes. */
|
||||
#define VIRTIO_SCSI_T_TMF 0
|
||||
#define VIRTIO_SCSI_T_AN_QUERY 1
|
||||
#define VIRTIO_SCSI_T_AN_SUBSCRIBE 2
|
||||
|
||||
/* Valid TMF subtypes. */
|
||||
#define VIRTIO_SCSI_T_TMF_ABORT_TASK 0
|
||||
#define VIRTIO_SCSI_T_TMF_ABORT_TASK_SET 1
|
||||
#define VIRTIO_SCSI_T_TMF_CLEAR_ACA 2
|
||||
#define VIRTIO_SCSI_T_TMF_CLEAR_TASK_SET 3
|
||||
#define VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET 4
|
||||
#define VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET 5
|
||||
#define VIRTIO_SCSI_T_TMF_QUERY_TASK 6
|
||||
#define VIRTIO_SCSI_T_TMF_QUERY_TASK_SET 7
|
||||
|
||||
/* Events. */
|
||||
#define VIRTIO_SCSI_T_EVENTS_MISSED 0x80000000
|
||||
#define VIRTIO_SCSI_T_NO_EVENT 0
|
||||
#define VIRTIO_SCSI_T_TRANSPORT_RESET 1
|
||||
#define VIRTIO_SCSI_T_ASYNC_NOTIFY 2
|
||||
#define VIRTIO_SCSI_T_PARAM_CHANGE 3
|
||||
|
||||
/* Reasons of transport reset event */
|
||||
#define VIRTIO_SCSI_EVT_RESET_HARD 0
|
||||
#define VIRTIO_SCSI_EVT_RESET_RESCAN 1
|
||||
#define VIRTIO_SCSI_EVT_RESET_REMOVED 2
|
||||
|
||||
#define VIRTIO_SCSI_S_SIMPLE 0
|
||||
#define VIRTIO_SCSI_S_ORDERED 1
|
||||
#define VIRTIO_SCSI_S_HEAD 2
|
||||
#define VIRTIO_SCSI_S_ACA 3
|
||||
|
||||
|
||||
#endif /* _LINUX_VIRTIO_SCSI_H */
|
||||
@@ -0,0 +1,488 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/*
|
||||
* Copyright (C) 2021 OpenSynergy GmbH
|
||||
*/
|
||||
#ifndef VIRTIO_SND_IF_H
|
||||
#define VIRTIO_SND_IF_H
|
||||
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* FEATURE BITS
|
||||
*/
|
||||
enum {
|
||||
/* device supports control elements */
|
||||
VIRTIO_SND_F_CTLS = 0
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* CONFIGURATION SPACE
|
||||
*/
|
||||
struct virtio_snd_config {
|
||||
/* # of available physical jacks */
|
||||
uint32_t jacks;
|
||||
/* # of available PCM streams */
|
||||
uint32_t streams;
|
||||
/* # of available channel maps */
|
||||
uint32_t chmaps;
|
||||
/* # of available control elements (if VIRTIO_SND_F_CTLS) */
|
||||
uint32_t controls;
|
||||
};
|
||||
|
||||
enum {
|
||||
/* device virtqueue indexes */
|
||||
VIRTIO_SND_VQ_CONTROL = 0,
|
||||
VIRTIO_SND_VQ_EVENT,
|
||||
VIRTIO_SND_VQ_TX,
|
||||
VIRTIO_SND_VQ_RX,
|
||||
/* # of device virtqueues */
|
||||
VIRTIO_SND_VQ_MAX
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* COMMON DEFINITIONS
|
||||
*/
|
||||
|
||||
/* supported dataflow directions */
|
||||
enum {
|
||||
VIRTIO_SND_D_OUTPUT = 0,
|
||||
VIRTIO_SND_D_INPUT
|
||||
};
|
||||
|
||||
enum {
|
||||
/* jack control request types */
|
||||
VIRTIO_SND_R_JACK_INFO = 1,
|
||||
VIRTIO_SND_R_JACK_REMAP,
|
||||
|
||||
/* PCM control request types */
|
||||
VIRTIO_SND_R_PCM_INFO = 0x0100,
|
||||
VIRTIO_SND_R_PCM_SET_PARAMS,
|
||||
VIRTIO_SND_R_PCM_PREPARE,
|
||||
VIRTIO_SND_R_PCM_RELEASE,
|
||||
VIRTIO_SND_R_PCM_START,
|
||||
VIRTIO_SND_R_PCM_STOP,
|
||||
|
||||
/* channel map control request types */
|
||||
VIRTIO_SND_R_CHMAP_INFO = 0x0200,
|
||||
|
||||
/* control element request types */
|
||||
VIRTIO_SND_R_CTL_INFO = 0x0300,
|
||||
VIRTIO_SND_R_CTL_ENUM_ITEMS,
|
||||
VIRTIO_SND_R_CTL_READ,
|
||||
VIRTIO_SND_R_CTL_WRITE,
|
||||
VIRTIO_SND_R_CTL_TLV_READ,
|
||||
VIRTIO_SND_R_CTL_TLV_WRITE,
|
||||
VIRTIO_SND_R_CTL_TLV_COMMAND,
|
||||
|
||||
/* jack event types */
|
||||
VIRTIO_SND_EVT_JACK_CONNECTED = 0x1000,
|
||||
VIRTIO_SND_EVT_JACK_DISCONNECTED,
|
||||
|
||||
/* PCM event types */
|
||||
VIRTIO_SND_EVT_PCM_PERIOD_ELAPSED = 0x1100,
|
||||
VIRTIO_SND_EVT_PCM_XRUN,
|
||||
|
||||
/* control element event types */
|
||||
VIRTIO_SND_EVT_CTL_NOTIFY = 0x1200,
|
||||
|
||||
/* common status codes */
|
||||
VIRTIO_SND_S_OK = 0x8000,
|
||||
VIRTIO_SND_S_BAD_MSG,
|
||||
VIRTIO_SND_S_NOT_SUPP,
|
||||
VIRTIO_SND_S_IO_ERR
|
||||
};
|
||||
|
||||
/* common header */
|
||||
struct virtio_snd_hdr {
|
||||
uint32_t code;
|
||||
};
|
||||
|
||||
/* event notification */
|
||||
struct virtio_snd_event {
|
||||
/* VIRTIO_SND_EVT_XXX */
|
||||
struct virtio_snd_hdr hdr;
|
||||
/* optional event data */
|
||||
uint32_t data;
|
||||
};
|
||||
|
||||
/* common control request to query an item information */
|
||||
struct virtio_snd_query_info {
|
||||
/* VIRTIO_SND_R_XXX_INFO */
|
||||
struct virtio_snd_hdr hdr;
|
||||
/* item start identifier */
|
||||
uint32_t start_id;
|
||||
/* item count to query */
|
||||
uint32_t count;
|
||||
/* item information size in bytes */
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
/* common item information header */
|
||||
struct virtio_snd_info {
|
||||
/* function group node id (High Definition Audio Specification 7.1.2) */
|
||||
uint32_t hda_fn_nid;
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* JACK CONTROL MESSAGES
|
||||
*/
|
||||
struct virtio_snd_jack_hdr {
|
||||
/* VIRTIO_SND_R_JACK_XXX */
|
||||
struct virtio_snd_hdr hdr;
|
||||
/* 0 ... virtio_snd_config::jacks - 1 */
|
||||
uint32_t jack_id;
|
||||
};
|
||||
|
||||
/* supported jack features */
|
||||
enum {
|
||||
VIRTIO_SND_JACK_F_REMAP = 0
|
||||
};
|
||||
|
||||
struct virtio_snd_jack_info {
|
||||
/* common header */
|
||||
struct virtio_snd_info hdr;
|
||||
/* supported feature bit map (1 << VIRTIO_SND_JACK_F_XXX) */
|
||||
uint32_t features;
|
||||
/* pin configuration (High Definition Audio Specification 7.3.3.31) */
|
||||
uint32_t hda_reg_defconf;
|
||||
/* pin capabilities (High Definition Audio Specification 7.3.4.9) */
|
||||
uint32_t hda_reg_caps;
|
||||
/* current jack connection status (0: disconnected, 1: connected) */
|
||||
uint8_t connected;
|
||||
|
||||
uint8_t padding[7];
|
||||
};
|
||||
|
||||
/* jack remapping control request */
|
||||
struct virtio_snd_jack_remap {
|
||||
/* .code = VIRTIO_SND_R_JACK_REMAP */
|
||||
struct virtio_snd_jack_hdr hdr;
|
||||
/* selected association number */
|
||||
uint32_t association;
|
||||
/* selected sequence number */
|
||||
uint32_t sequence;
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* PCM CONTROL MESSAGES
|
||||
*/
|
||||
struct virtio_snd_pcm_hdr {
|
||||
/* VIRTIO_SND_R_PCM_XXX */
|
||||
struct virtio_snd_hdr hdr;
|
||||
/* 0 ... virtio_snd_config::streams - 1 */
|
||||
uint32_t stream_id;
|
||||
};
|
||||
|
||||
/* supported PCM stream features */
|
||||
enum {
|
||||
VIRTIO_SND_PCM_F_SHMEM_HOST = 0,
|
||||
VIRTIO_SND_PCM_F_SHMEM_GUEST,
|
||||
VIRTIO_SND_PCM_F_MSG_POLLING,
|
||||
VIRTIO_SND_PCM_F_EVT_SHMEM_PERIODS,
|
||||
VIRTIO_SND_PCM_F_EVT_XRUNS
|
||||
};
|
||||
|
||||
/* supported PCM sample formats */
|
||||
enum {
|
||||
/* analog formats (width / physical width) */
|
||||
VIRTIO_SND_PCM_FMT_IMA_ADPCM = 0, /* 4 / 4 bits */
|
||||
VIRTIO_SND_PCM_FMT_MU_LAW, /* 8 / 8 bits */
|
||||
VIRTIO_SND_PCM_FMT_A_LAW, /* 8 / 8 bits */
|
||||
VIRTIO_SND_PCM_FMT_S8, /* 8 / 8 bits */
|
||||
VIRTIO_SND_PCM_FMT_U8, /* 8 / 8 bits */
|
||||
VIRTIO_SND_PCM_FMT_S16, /* 16 / 16 bits */
|
||||
VIRTIO_SND_PCM_FMT_U16, /* 16 / 16 bits */
|
||||
VIRTIO_SND_PCM_FMT_S18_3, /* 18 / 24 bits */
|
||||
VIRTIO_SND_PCM_FMT_U18_3, /* 18 / 24 bits */
|
||||
VIRTIO_SND_PCM_FMT_S20_3, /* 20 / 24 bits */
|
||||
VIRTIO_SND_PCM_FMT_U20_3, /* 20 / 24 bits */
|
||||
VIRTIO_SND_PCM_FMT_S24_3, /* 24 / 24 bits */
|
||||
VIRTIO_SND_PCM_FMT_U24_3, /* 24 / 24 bits */
|
||||
VIRTIO_SND_PCM_FMT_S20, /* 20 / 32 bits */
|
||||
VIRTIO_SND_PCM_FMT_U20, /* 20 / 32 bits */
|
||||
VIRTIO_SND_PCM_FMT_S24, /* 24 / 32 bits */
|
||||
VIRTIO_SND_PCM_FMT_U24, /* 24 / 32 bits */
|
||||
VIRTIO_SND_PCM_FMT_S32, /* 32 / 32 bits */
|
||||
VIRTIO_SND_PCM_FMT_U32, /* 32 / 32 bits */
|
||||
VIRTIO_SND_PCM_FMT_FLOAT, /* 32 / 32 bits */
|
||||
VIRTIO_SND_PCM_FMT_FLOAT64, /* 64 / 64 bits */
|
||||
/* digital formats (width / physical width) */
|
||||
VIRTIO_SND_PCM_FMT_DSD_U8, /* 8 / 8 bits */
|
||||
VIRTIO_SND_PCM_FMT_DSD_U16, /* 16 / 16 bits */
|
||||
VIRTIO_SND_PCM_FMT_DSD_U32, /* 32 / 32 bits */
|
||||
VIRTIO_SND_PCM_FMT_IEC958_SUBFRAME /* 32 / 32 bits */
|
||||
};
|
||||
|
||||
/* supported PCM frame rates */
|
||||
enum {
|
||||
VIRTIO_SND_PCM_RATE_5512 = 0,
|
||||
VIRTIO_SND_PCM_RATE_8000,
|
||||
VIRTIO_SND_PCM_RATE_11025,
|
||||
VIRTIO_SND_PCM_RATE_16000,
|
||||
VIRTIO_SND_PCM_RATE_22050,
|
||||
VIRTIO_SND_PCM_RATE_32000,
|
||||
VIRTIO_SND_PCM_RATE_44100,
|
||||
VIRTIO_SND_PCM_RATE_48000,
|
||||
VIRTIO_SND_PCM_RATE_64000,
|
||||
VIRTIO_SND_PCM_RATE_88200,
|
||||
VIRTIO_SND_PCM_RATE_96000,
|
||||
VIRTIO_SND_PCM_RATE_176400,
|
||||
VIRTIO_SND_PCM_RATE_192000,
|
||||
VIRTIO_SND_PCM_RATE_384000
|
||||
};
|
||||
|
||||
struct virtio_snd_pcm_info {
|
||||
/* common header */
|
||||
struct virtio_snd_info hdr;
|
||||
/* supported feature bit map (1 << VIRTIO_SND_PCM_F_XXX) */
|
||||
uint32_t features;
|
||||
/* supported sample format bit map (1 << VIRTIO_SND_PCM_FMT_XXX) */
|
||||
uint64_t formats;
|
||||
/* supported frame rate bit map (1 << VIRTIO_SND_PCM_RATE_XXX) */
|
||||
uint64_t rates;
|
||||
/* dataflow direction (VIRTIO_SND_D_XXX) */
|
||||
uint8_t direction;
|
||||
/* minimum # of supported channels */
|
||||
uint8_t channels_min;
|
||||
/* maximum # of supported channels */
|
||||
uint8_t channels_max;
|
||||
|
||||
uint8_t padding[5];
|
||||
};
|
||||
|
||||
/* set PCM stream format */
|
||||
struct virtio_snd_pcm_set_params {
|
||||
/* .code = VIRTIO_SND_R_PCM_SET_PARAMS */
|
||||
struct virtio_snd_pcm_hdr hdr;
|
||||
/* size of the hardware buffer */
|
||||
uint32_t buffer_bytes;
|
||||
/* size of the hardware period */
|
||||
uint32_t period_bytes;
|
||||
/* selected feature bit map (1 << VIRTIO_SND_PCM_F_XXX) */
|
||||
uint32_t features;
|
||||
/* selected # of channels */
|
||||
uint8_t channels;
|
||||
/* selected sample format (VIRTIO_SND_PCM_FMT_XXX) */
|
||||
uint8_t format;
|
||||
/* selected frame rate (VIRTIO_SND_PCM_RATE_XXX) */
|
||||
uint8_t rate;
|
||||
|
||||
uint8_t padding;
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* PCM I/O MESSAGES
|
||||
*/
|
||||
|
||||
/* I/O request header */
|
||||
struct virtio_snd_pcm_xfer {
|
||||
/* 0 ... virtio_snd_config::streams - 1 */
|
||||
uint32_t stream_id;
|
||||
};
|
||||
|
||||
/* I/O request status */
|
||||
struct virtio_snd_pcm_status {
|
||||
/* VIRTIO_SND_S_XXX */
|
||||
uint32_t status;
|
||||
/* current device latency */
|
||||
uint32_t latency_bytes;
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* CHANNEL MAP CONTROL MESSAGES
|
||||
*/
|
||||
struct virtio_snd_chmap_hdr {
|
||||
/* VIRTIO_SND_R_CHMAP_XXX */
|
||||
struct virtio_snd_hdr hdr;
|
||||
/* 0 ... virtio_snd_config::chmaps - 1 */
|
||||
uint32_t chmap_id;
|
||||
};
|
||||
|
||||
/* standard channel position definition */
|
||||
enum {
|
||||
VIRTIO_SND_CHMAP_NONE = 0, /* undefined */
|
||||
VIRTIO_SND_CHMAP_NA, /* silent */
|
||||
VIRTIO_SND_CHMAP_MONO, /* mono stream */
|
||||
VIRTIO_SND_CHMAP_FL, /* front left */
|
||||
VIRTIO_SND_CHMAP_FR, /* front right */
|
||||
VIRTIO_SND_CHMAP_RL, /* rear left */
|
||||
VIRTIO_SND_CHMAP_RR, /* rear right */
|
||||
VIRTIO_SND_CHMAP_FC, /* front center */
|
||||
VIRTIO_SND_CHMAP_LFE, /* low frequency (LFE) */
|
||||
VIRTIO_SND_CHMAP_SL, /* side left */
|
||||
VIRTIO_SND_CHMAP_SR, /* side right */
|
||||
VIRTIO_SND_CHMAP_RC, /* rear center */
|
||||
VIRTIO_SND_CHMAP_FLC, /* front left center */
|
||||
VIRTIO_SND_CHMAP_FRC, /* front right center */
|
||||
VIRTIO_SND_CHMAP_RLC, /* rear left center */
|
||||
VIRTIO_SND_CHMAP_RRC, /* rear right center */
|
||||
VIRTIO_SND_CHMAP_FLW, /* front left wide */
|
||||
VIRTIO_SND_CHMAP_FRW, /* front right wide */
|
||||
VIRTIO_SND_CHMAP_FLH, /* front left high */
|
||||
VIRTIO_SND_CHMAP_FCH, /* front center high */
|
||||
VIRTIO_SND_CHMAP_FRH, /* front right high */
|
||||
VIRTIO_SND_CHMAP_TC, /* top center */
|
||||
VIRTIO_SND_CHMAP_TFL, /* top front left */
|
||||
VIRTIO_SND_CHMAP_TFR, /* top front right */
|
||||
VIRTIO_SND_CHMAP_TFC, /* top front center */
|
||||
VIRTIO_SND_CHMAP_TRL, /* top rear left */
|
||||
VIRTIO_SND_CHMAP_TRR, /* top rear right */
|
||||
VIRTIO_SND_CHMAP_TRC, /* top rear center */
|
||||
VIRTIO_SND_CHMAP_TFLC, /* top front left center */
|
||||
VIRTIO_SND_CHMAP_TFRC, /* top front right center */
|
||||
VIRTIO_SND_CHMAP_TSL, /* top side left */
|
||||
VIRTIO_SND_CHMAP_TSR, /* top side right */
|
||||
VIRTIO_SND_CHMAP_LLFE, /* left LFE */
|
||||
VIRTIO_SND_CHMAP_RLFE, /* right LFE */
|
||||
VIRTIO_SND_CHMAP_BC, /* bottom center */
|
||||
VIRTIO_SND_CHMAP_BLC, /* bottom left center */
|
||||
VIRTIO_SND_CHMAP_BRC /* bottom right center */
|
||||
};
|
||||
|
||||
/* maximum possible number of channels */
|
||||
#define VIRTIO_SND_CHMAP_MAX_SIZE 18
|
||||
|
||||
struct virtio_snd_chmap_info {
|
||||
/* common header */
|
||||
struct virtio_snd_info hdr;
|
||||
/* dataflow direction (VIRTIO_SND_D_XXX) */
|
||||
uint8_t direction;
|
||||
/* # of valid channel position values */
|
||||
uint8_t channels;
|
||||
/* channel position values (VIRTIO_SND_CHMAP_XXX) */
|
||||
uint8_t positions[VIRTIO_SND_CHMAP_MAX_SIZE];
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* CONTROL ELEMENTS MESSAGES
|
||||
*/
|
||||
struct virtio_snd_ctl_hdr {
|
||||
/* VIRTIO_SND_R_CTL_XXX */
|
||||
struct virtio_snd_hdr hdr;
|
||||
/* 0 ... virtio_snd_config::controls - 1 */
|
||||
uint32_t control_id;
|
||||
};
|
||||
|
||||
/* supported roles for control elements */
|
||||
enum {
|
||||
VIRTIO_SND_CTL_ROLE_UNDEFINED = 0,
|
||||
VIRTIO_SND_CTL_ROLE_VOLUME,
|
||||
VIRTIO_SND_CTL_ROLE_MUTE,
|
||||
VIRTIO_SND_CTL_ROLE_GAIN
|
||||
};
|
||||
|
||||
/* supported value types for control elements */
|
||||
enum {
|
||||
VIRTIO_SND_CTL_TYPE_BOOLEAN = 0,
|
||||
VIRTIO_SND_CTL_TYPE_INTEGER,
|
||||
VIRTIO_SND_CTL_TYPE_INTEGER64,
|
||||
VIRTIO_SND_CTL_TYPE_ENUMERATED,
|
||||
VIRTIO_SND_CTL_TYPE_BYTES,
|
||||
VIRTIO_SND_CTL_TYPE_IEC958
|
||||
};
|
||||
|
||||
/* supported access rights for control elements */
|
||||
enum {
|
||||
VIRTIO_SND_CTL_ACCESS_READ = 0,
|
||||
VIRTIO_SND_CTL_ACCESS_WRITE,
|
||||
VIRTIO_SND_CTL_ACCESS_VOLATILE,
|
||||
VIRTIO_SND_CTL_ACCESS_INACTIVE,
|
||||
VIRTIO_SND_CTL_ACCESS_TLV_READ,
|
||||
VIRTIO_SND_CTL_ACCESS_TLV_WRITE,
|
||||
VIRTIO_SND_CTL_ACCESS_TLV_COMMAND
|
||||
};
|
||||
|
||||
struct virtio_snd_ctl_info {
|
||||
/* common header */
|
||||
struct virtio_snd_info hdr;
|
||||
/* element role (VIRTIO_SND_CTL_ROLE_XXX) */
|
||||
uint32_t role;
|
||||
/* element value type (VIRTIO_SND_CTL_TYPE_XXX) */
|
||||
uint32_t type;
|
||||
/* element access right bit map (1 << VIRTIO_SND_CTL_ACCESS_XXX) */
|
||||
uint32_t access;
|
||||
/* # of members in the element value */
|
||||
uint32_t count;
|
||||
/* index for an element with a non-unique name */
|
||||
uint32_t index;
|
||||
/* name identifier string for the element */
|
||||
uint8_t name[44];
|
||||
/* additional information about the element's value */
|
||||
union {
|
||||
/* VIRTIO_SND_CTL_TYPE_INTEGER */
|
||||
struct {
|
||||
/* minimum supported value */
|
||||
uint32_t min;
|
||||
/* maximum supported value */
|
||||
uint32_t max;
|
||||
/* fixed step size for value (0 = variable size) */
|
||||
uint32_t step;
|
||||
} integer;
|
||||
/* VIRTIO_SND_CTL_TYPE_INTEGER64 */
|
||||
struct {
|
||||
/* minimum supported value */
|
||||
uint64_t min;
|
||||
/* maximum supported value */
|
||||
uint64_t max;
|
||||
/* fixed step size for value (0 = variable size) */
|
||||
uint64_t step;
|
||||
} integer64;
|
||||
/* VIRTIO_SND_CTL_TYPE_ENUMERATED */
|
||||
struct {
|
||||
/* # of options supported for value */
|
||||
uint32_t items;
|
||||
} enumerated;
|
||||
} value;
|
||||
};
|
||||
|
||||
struct virtio_snd_ctl_enum_item {
|
||||
/* option name */
|
||||
uint8_t item[64];
|
||||
};
|
||||
|
||||
struct virtio_snd_ctl_iec958 {
|
||||
/* AES/IEC958 channel status bits */
|
||||
uint8_t status[24];
|
||||
/* AES/IEC958 subcode bits */
|
||||
uint8_t subcode[147];
|
||||
/* nothing */
|
||||
uint8_t pad;
|
||||
/* AES/IEC958 subframe bits */
|
||||
uint8_t dig_subframe[4];
|
||||
};
|
||||
|
||||
struct virtio_snd_ctl_value {
|
||||
union {
|
||||
/* VIRTIO_SND_CTL_TYPE_BOOLEAN|INTEGER value */
|
||||
uint32_t integer[128];
|
||||
/* VIRTIO_SND_CTL_TYPE_INTEGER64 value */
|
||||
uint64_t integer64[64];
|
||||
/* VIRTIO_SND_CTL_TYPE_ENUMERATED value (option indexes) */
|
||||
uint32_t enumerated[128];
|
||||
/* VIRTIO_SND_CTL_TYPE_BYTES value */
|
||||
uint8_t bytes[512];
|
||||
/* VIRTIO_SND_CTL_TYPE_IEC958 value */
|
||||
struct virtio_snd_ctl_iec958 iec958;
|
||||
} value;
|
||||
};
|
||||
|
||||
/* supported event reason types */
|
||||
enum {
|
||||
/* element's value has changed */
|
||||
VIRTIO_SND_CTL_EVT_MASK_VALUE = 0,
|
||||
/* element's information has changed */
|
||||
VIRTIO_SND_CTL_EVT_MASK_INFO,
|
||||
/* element's metadata has changed */
|
||||
VIRTIO_SND_CTL_EVT_MASK_TLV
|
||||
};
|
||||
|
||||
struct virtio_snd_ctl_event {
|
||||
/* VIRTIO_SND_EVT_CTL_NOTIFY */
|
||||
struct virtio_snd_hdr hdr;
|
||||
/* 0 ... virtio_snd_config::controls - 1 */
|
||||
uint16_t control_id;
|
||||
/* event reason bit map (1 << VIRTIO_SND_CTL_EVT_MASK_XXX) */
|
||||
uint16_t mask;
|
||||
};
|
||||
|
||||
#endif /* VIRTIO_SND_IF_H */
|
||||
@@ -0,0 +1,181 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
/*
|
||||
* Copyright (C) 2023 OpenSynergy GmbH
|
||||
* Copyright (C) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef _LINUX_VIRTIO_VIRTIO_SPI_H
|
||||
#define _LINUX_VIRTIO_VIRTIO_SPI_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_types.h"
|
||||
|
||||
/* Sample data on trailing clock edge */
|
||||
#define VIRTIO_SPI_CPHA _BITUL(0)
|
||||
/* Clock is high when IDLE */
|
||||
#define VIRTIO_SPI_CPOL _BITUL(1)
|
||||
/* Chip Select is active high */
|
||||
#define VIRTIO_SPI_CS_HIGH _BITUL(2)
|
||||
/* Transmit LSB first */
|
||||
#define VIRTIO_SPI_MODE_LSB_FIRST _BITUL(3)
|
||||
/* Loopback mode */
|
||||
#define VIRTIO_SPI_MODE_LOOP _BITUL(4)
|
||||
|
||||
/**
|
||||
* struct virtio_spi_config - All config fields are read-only for the
|
||||
* Virtio SPI driver
|
||||
* @cs_max_number: maximum number of chipselect the host SPI controller
|
||||
* supports.
|
||||
* @cs_change_supported: indicates if the host SPI controller supports to toggle
|
||||
* chipselect after each transfer in one message:
|
||||
* 0: unsupported, chipselect will be kept in active state throughout the
|
||||
* message transaction;
|
||||
* 1: supported.
|
||||
* Note: Message here contains a sequence of SPI transfers.
|
||||
* @tx_nbits_supported: indicates the supported number of bit for writing:
|
||||
* bit 0: DUAL (2-bit transfer), 1 for supported
|
||||
* bit 1: QUAD (4-bit transfer), 1 for supported
|
||||
* bit 2: OCTAL (8-bit transfer), 1 for supported
|
||||
* other bits are reserved as 0, 1-bit transfer is always supported.
|
||||
* @rx_nbits_supported: indicates the supported number of bit for reading:
|
||||
* bit 0: DUAL (2-bit transfer), 1 for supported
|
||||
* bit 1: QUAD (4-bit transfer), 1 for supported
|
||||
* bit 2: OCTAL (8-bit transfer), 1 for supported
|
||||
* other bits are reserved as 0, 1-bit transfer is always supported.
|
||||
* @bits_per_word_mask: mask indicating which values of bits_per_word are
|
||||
* supported. If not set, no limitation for bits_per_word.
|
||||
* @mode_func_supported: indicates the following features are supported or not:
|
||||
* bit 0-1: CPHA feature
|
||||
* 0b00: invalid, should support as least one CPHA setting
|
||||
* 0b01: supports CPHA=0 only
|
||||
* 0b10: supports CPHA=1 only
|
||||
* 0b11: supports CPHA=0 and CPHA=1.
|
||||
* bit 2-3: CPOL feature
|
||||
* 0b00: invalid, should support as least one CPOL setting
|
||||
* 0b01: supports CPOL=0 only
|
||||
* 0b10: supports CPOL=1 only
|
||||
* 0b11: supports CPOL=0 and CPOL=1.
|
||||
* bit 4: chipselect active high feature, 0 for unsupported and 1 for
|
||||
* supported, chipselect active low is supported by default.
|
||||
* bit 5: LSB first feature, 0 for unsupported and 1 for supported,
|
||||
* MSB first is supported by default.
|
||||
* bit 6: loopback mode feature, 0 for unsupported and 1 for supported,
|
||||
* normal mode is supported by default.
|
||||
* @max_freq_hz: the maximum clock rate supported in Hz unit, 0 means no
|
||||
* limitation for transfer speed.
|
||||
* @max_word_delay_ns: the maximum word delay supported, in nanoseconds.
|
||||
* A value of 0 indicates that word delay is unsupported.
|
||||
* Each transfer may consist of a sequence of words.
|
||||
* @max_cs_setup_ns: the maximum delay supported after chipselect is asserted,
|
||||
* in ns unit, 0 means delay is not supported to introduce after chipselect is
|
||||
* asserted.
|
||||
* @max_cs_hold_ns: the maximum delay supported before chipselect is deasserted,
|
||||
* in ns unit, 0 means delay is not supported to introduce before chipselect
|
||||
* is deasserted.
|
||||
* @max_cs_incative_ns: maximum delay supported after chipselect is deasserted,
|
||||
* in ns unit, 0 means delay is not supported to introduce after chipselect is
|
||||
* deasserted.
|
||||
*/
|
||||
struct virtio_spi_config {
|
||||
uint8_t cs_max_number;
|
||||
uint8_t cs_change_supported;
|
||||
#define VIRTIO_SPI_RX_TX_SUPPORT_DUAL _BITUL(0)
|
||||
#define VIRTIO_SPI_RX_TX_SUPPORT_QUAD _BITUL(1)
|
||||
#define VIRTIO_SPI_RX_TX_SUPPORT_OCTAL _BITUL(2)
|
||||
uint8_t tx_nbits_supported;
|
||||
uint8_t rx_nbits_supported;
|
||||
uint32_t bits_per_word_mask;
|
||||
#define VIRTIO_SPI_MF_SUPPORT_CPHA_0 _BITUL(0)
|
||||
#define VIRTIO_SPI_MF_SUPPORT_CPHA_1 _BITUL(1)
|
||||
#define VIRTIO_SPI_MF_SUPPORT_CPOL_0 _BITUL(2)
|
||||
#define VIRTIO_SPI_MF_SUPPORT_CPOL_1 _BITUL(3)
|
||||
#define VIRTIO_SPI_MF_SUPPORT_CS_HIGH _BITUL(4)
|
||||
#define VIRTIO_SPI_MF_SUPPORT_LSB_FIRST _BITUL(5)
|
||||
#define VIRTIO_SPI_MF_SUPPORT_LOOPBACK _BITUL(6)
|
||||
uint32_t mode_func_supported;
|
||||
uint32_t max_freq_hz;
|
||||
uint32_t max_word_delay_ns;
|
||||
uint32_t max_cs_setup_ns;
|
||||
uint32_t max_cs_hold_ns;
|
||||
uint32_t max_cs_inactive_ns;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct spi_transfer_head - virtio SPI transfer descriptor
|
||||
* @chip_select_id: chipselect index the SPI transfer used.
|
||||
* @bits_per_word: the number of bits in each SPI transfer word.
|
||||
* @cs_change: whether to deselect device after finishing this transfer
|
||||
* before starting the next transfer, 0 means cs keep asserted and
|
||||
* 1 means cs deasserted then asserted again.
|
||||
* @tx_nbits: bus width for write transfer.
|
||||
* 0,1: bus width is 1, also known as SINGLE
|
||||
* 2 : bus width is 2, also known as DUAL
|
||||
* 4 : bus width is 4, also known as QUAD
|
||||
* 8 : bus width is 8, also known as OCTAL
|
||||
* other values are invalid.
|
||||
* @rx_nbits: bus width for read transfer.
|
||||
* 0,1: bus width is 1, also known as SINGLE
|
||||
* 2 : bus width is 2, also known as DUAL
|
||||
* 4 : bus width is 4, also known as QUAD
|
||||
* 8 : bus width is 8, also known as OCTAL
|
||||
* other values are invalid.
|
||||
* @reserved: for future use.
|
||||
* @mode: SPI transfer mode.
|
||||
* bit 0: CPHA, determines the timing (i.e. phase) of the data
|
||||
* bits relative to the clock pulses.For CPHA=0, the
|
||||
* "out" side changes the data on the trailing edge of the
|
||||
* preceding clock cycle, while the "in" side captures the data
|
||||
* on (or shortly after) the leading edge of the clock cycle.
|
||||
* For CPHA=1, the "out" side changes the data on the leading
|
||||
* edge of the current clock cycle, while the "in" side
|
||||
* captures the data on (or shortly after) the trailing edge of
|
||||
* the clock cycle.
|
||||
* bit 1: CPOL, determines the polarity of the clock. CPOL=0 is a
|
||||
* clock which idles at 0, and each cycle consists of a pulse
|
||||
* of 1. CPOL=1 is a clock which idles at 1, and each cycle
|
||||
* consists of a pulse of 0.
|
||||
* bit 2: CS_HIGH, if 1, chip select active high, else active low.
|
||||
* bit 3: LSB_FIRST, determines per-word bits-on-wire, if 0, MSB
|
||||
* first, else LSB first.
|
||||
* bit 4: LOOP, loopback mode.
|
||||
* @freq: the transfer speed in Hz.
|
||||
* @word_delay_ns: delay to be inserted between consecutive words of a
|
||||
* transfer, in ns unit.
|
||||
* @cs_setup_ns: delay to be introduced after CS is asserted, in ns
|
||||
* unit.
|
||||
* @cs_delay_hold_ns: delay to be introduced before CS is deasserted
|
||||
* for each transfer, in ns unit.
|
||||
* @cs_change_delay_inactive_ns: delay to be introduced after CS is
|
||||
* deasserted and before next asserted, in ns unit.
|
||||
*/
|
||||
struct spi_transfer_head {
|
||||
uint8_t chip_select_id;
|
||||
uint8_t bits_per_word;
|
||||
uint8_t cs_change;
|
||||
uint8_t tx_nbits;
|
||||
uint8_t rx_nbits;
|
||||
uint8_t reserved[3];
|
||||
uint32_t mode;
|
||||
uint32_t freq;
|
||||
uint32_t word_delay_ns;
|
||||
uint32_t cs_setup_ns;
|
||||
uint32_t cs_delay_hold_ns;
|
||||
uint32_t cs_change_delay_inactive_ns;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct spi_transfer_result - virtio SPI transfer result
|
||||
* @result: Transfer result code.
|
||||
* VIRTIO_SPI_TRANS_OK: Transfer successful.
|
||||
* VIRTIO_SPI_PARAM_ERR: Parameter error.
|
||||
* VIRTIO_SPI_TRANS_ERR: Transfer error.
|
||||
*/
|
||||
struct spi_transfer_result {
|
||||
#define VIRTIO_SPI_TRANS_OK 0
|
||||
#define VIRTIO_SPI_PARAM_ERR 1
|
||||
#define VIRTIO_SPI_TRANS_ERR 2
|
||||
uint8_t result;
|
||||
};
|
||||
|
||||
#endif /* #ifndef _LINUX_VIRTIO_VIRTIO_SPI_H */
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef _LINUX_VIRTIO_TYPES_H
|
||||
#define _LINUX_VIRTIO_TYPES_H
|
||||
/* Type definitions for virtio implementations.
|
||||
*
|
||||
* This header is BSD licensed so anyone can use the definitions to implement
|
||||
* compatible drivers/servers.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Copyright (C) 2014 Red Hat, Inc.
|
||||
* Author: Michael S. Tsirkin <[email protected]>
|
||||
*/
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
/*
|
||||
* __virtio{16,32,64} have the following meaning:
|
||||
* - __u{16,32,64} for virtio devices in legacy mode, accessed in native endian
|
||||
* - __le{16,32,64} for standard-compliant virtio devices
|
||||
*/
|
||||
|
||||
typedef uint16_t __virtio16;
|
||||
typedef uint32_t __virtio32;
|
||||
typedef uint64_t __virtio64;
|
||||
|
||||
#endif /* _LINUX_VIRTIO_TYPES_H */
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so
|
||||
* anyone can use the definitions to implement compatible drivers/servers:
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of IBM nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Copyright (C) Red Hat, Inc., 2013-2015
|
||||
* Copyright (C) Asias He <[email protected]>, 2013
|
||||
* Copyright (C) Stefan Hajnoczi <[email protected]>, 2015
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_VIRTIO_VSOCK_H
|
||||
#define _LINUX_VIRTIO_VSOCK_H
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
#include "standard-headers/linux/virtio_ids.h"
|
||||
#include "standard-headers/linux/virtio_config.h"
|
||||
|
||||
/* The feature bitmap for virtio vsock */
|
||||
#define VIRTIO_VSOCK_F_SEQPACKET 1 /* SOCK_SEQPACKET supported */
|
||||
|
||||
struct virtio_vsock_config {
|
||||
uint64_t guest_cid;
|
||||
} QEMU_PACKED;
|
||||
|
||||
enum virtio_vsock_event_id {
|
||||
VIRTIO_VSOCK_EVENT_TRANSPORT_RESET = 0,
|
||||
};
|
||||
|
||||
struct virtio_vsock_event {
|
||||
uint32_t id;
|
||||
} QEMU_PACKED;
|
||||
|
||||
struct virtio_vsock_hdr {
|
||||
uint64_t src_cid;
|
||||
uint64_t dst_cid;
|
||||
uint32_t src_port;
|
||||
uint32_t dst_port;
|
||||
uint32_t len;
|
||||
uint16_t type; /* enum virtio_vsock_type */
|
||||
uint16_t op; /* enum virtio_vsock_op */
|
||||
uint32_t flags;
|
||||
uint32_t buf_alloc;
|
||||
uint32_t fwd_cnt;
|
||||
} QEMU_PACKED;
|
||||
|
||||
enum virtio_vsock_type {
|
||||
VIRTIO_VSOCK_TYPE_STREAM = 1,
|
||||
VIRTIO_VSOCK_TYPE_SEQPACKET = 2,
|
||||
};
|
||||
|
||||
enum virtio_vsock_op {
|
||||
VIRTIO_VSOCK_OP_INVALID = 0,
|
||||
|
||||
/* Connect operations */
|
||||
VIRTIO_VSOCK_OP_REQUEST = 1,
|
||||
VIRTIO_VSOCK_OP_RESPONSE = 2,
|
||||
VIRTIO_VSOCK_OP_RST = 3,
|
||||
VIRTIO_VSOCK_OP_SHUTDOWN = 4,
|
||||
|
||||
/* To send payload */
|
||||
VIRTIO_VSOCK_OP_RW = 5,
|
||||
|
||||
/* Tell the peer our credit info */
|
||||
VIRTIO_VSOCK_OP_CREDIT_UPDATE = 6,
|
||||
/* Request the peer to send the credit info to us */
|
||||
VIRTIO_VSOCK_OP_CREDIT_REQUEST = 7,
|
||||
};
|
||||
|
||||
/* VIRTIO_VSOCK_OP_SHUTDOWN flags values */
|
||||
enum virtio_vsock_shutdown {
|
||||
VIRTIO_VSOCK_SHUTDOWN_RCV = 1,
|
||||
VIRTIO_VSOCK_SHUTDOWN_SEND = 2,
|
||||
};
|
||||
|
||||
/* VIRTIO_VSOCK_OP_RW flags values */
|
||||
enum virtio_vsock_rw {
|
||||
VIRTIO_VSOCK_SEQ_EOM = 1,
|
||||
VIRTIO_VSOCK_SEQ_EOR = 2,
|
||||
};
|
||||
|
||||
#endif /* _LINUX_VIRTIO_VSOCK_H */
|
||||
@@ -0,0 +1,202 @@
|
||||
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
|
||||
|
||||
/*
|
||||
* This structure provides a vDSO-style clock to VM guests, exposing the
|
||||
* relationship (or lack thereof) between the CPU clock (TSC, timebase, arch
|
||||
* counter, etc.) and real time. It is designed to address the problem of
|
||||
* live migration, which other clock enlightenments do not.
|
||||
*
|
||||
* When a guest is live migrated, this affects the clock in two ways.
|
||||
*
|
||||
* First, even between identical hosts the actual frequency of the underlying
|
||||
* counter will change within the tolerances of its specification (typically
|
||||
* ±50PPM, or 4 seconds a day). This frequency also varies over time on the
|
||||
* same host, but can be tracked by NTP as it generally varies slowly. With
|
||||
* live migration there is a step change in the frequency, with no warning.
|
||||
*
|
||||
* Second, there may be a step change in the value of the counter itself, as
|
||||
* its accuracy is limited by the precision of the NTP synchronization on the
|
||||
* source and destination hosts.
|
||||
*
|
||||
* So any calibration (NTP, PTP, etc.) which the guest has done on the source
|
||||
* host before migration is invalid, and needs to be redone on the new host.
|
||||
*
|
||||
* In its most basic mode, this structure provides only an indication to the
|
||||
* guest that live migration has occurred. This allows the guest to know that
|
||||
* its clock is invalid and take remedial action. For applications that need
|
||||
* reliable accurate timestamps (e.g. distributed databases), the structure
|
||||
* can be mapped all the way to userspace. This allows the application to see
|
||||
* directly for itself that the clock is disrupted and take appropriate
|
||||
* action, even when using a vDSO-style method to get the time instead of a
|
||||
* system call.
|
||||
*
|
||||
* In its more advanced mode. this structure can also be used to expose the
|
||||
* precise relationship of the CPU counter to real time, as calibrated by the
|
||||
* host. This means that userspace applications can have accurate time
|
||||
* immediately after live migration, rather than having to pause operations
|
||||
* and wait for NTP to recover. This mode does, of course, rely on the
|
||||
* counter being reliable and consistent across CPUs.
|
||||
*
|
||||
* Note that this must be true UTC, never with smeared leap seconds. If a
|
||||
* guest wishes to construct a smeared clock, it can do so. Presenting a
|
||||
* smeared clock through this interface would be problematic because it
|
||||
* actually messes with the apparent counter *period*. A linear smearing
|
||||
* of 1 ms per second would effectively tweak the counter period by 1000PPM
|
||||
* at the start/end of the smearing period, while a sinusoidal smear would
|
||||
* basically be impossible to represent.
|
||||
*
|
||||
* This structure is offered with the intent that it be adopted into the
|
||||
* nascent virtio-rtc standard, as a virtio-rtc that does not address the live
|
||||
* migration problem seems a little less than fit for purpose. For that
|
||||
* reason, certain fields use precisely the same numeric definitions as in
|
||||
* the virtio-rtc proposal. The structure can also be exposed through an ACPI
|
||||
* device with the CID "VMCLOCK", modelled on the "VMGENID" device except for
|
||||
* the fact that it uses a real _CRS to convey the address of the structure
|
||||
* (which should be a full page, to allow for mapping directly to userspace).
|
||||
*/
|
||||
|
||||
#ifndef __VMCLOCK_ABI_H__
|
||||
#define __VMCLOCK_ABI_H__
|
||||
|
||||
#include "standard-headers/linux/types.h"
|
||||
|
||||
struct vmclock_abi {
|
||||
/* CONSTANT FIELDS */
|
||||
uint32_t magic;
|
||||
#define VMCLOCK_MAGIC 0x4b4c4356 /* "VCLK" */
|
||||
uint32_t size; /* Size of region containing this structure */
|
||||
uint16_t version; /* 1 */
|
||||
uint8_t counter_id; /* Matches VIRTIO_RTC_COUNTER_xxx except INVALID */
|
||||
#define VMCLOCK_COUNTER_ARM_VCNT 0
|
||||
#define VMCLOCK_COUNTER_X86_TSC 1
|
||||
#define VMCLOCK_COUNTER_INVALID 0xff
|
||||
uint8_t time_type; /* Matches VIRTIO_RTC_TYPE_xxx */
|
||||
#define VMCLOCK_TIME_UTC 0 /* Since 1970-01-01 00:00:00z */
|
||||
#define VMCLOCK_TIME_TAI 1 /* Since 1970-01-01 00:00:00z */
|
||||
#define VMCLOCK_TIME_MONOTONIC 2 /* Since undefined epoch */
|
||||
#define VMCLOCK_TIME_INVALID_SMEARED 3 /* Not supported */
|
||||
#define VMCLOCK_TIME_INVALID_MAYBE_SMEARED 4 /* Not supported */
|
||||
|
||||
/* NON-CONSTANT FIELDS PROTECTED BY SEQCOUNT LOCK */
|
||||
uint32_t seq_count; /* Low bit means an update is in progress */
|
||||
/*
|
||||
* This field changes to another non-repeating value when the CPU
|
||||
* counter is disrupted, for example on live migration. This lets
|
||||
* the guest know that it should discard any calibration it has
|
||||
* performed of the counter against external sources (NTP/PTP/etc.).
|
||||
*/
|
||||
uint64_t disruption_marker;
|
||||
uint64_t flags;
|
||||
/* Indicates that the tai_offset_sec field is valid */
|
||||
#define VMCLOCK_FLAG_TAI_OFFSET_VALID (1 << 0)
|
||||
/*
|
||||
* Optionally used to notify guests of pending maintenance events.
|
||||
* A guest which provides latency-sensitive services may wish to
|
||||
* remove itself from service if an event is coming up. Two flags
|
||||
* indicate the approximate imminence of the event.
|
||||
*/
|
||||
#define VMCLOCK_FLAG_DISRUPTION_SOON (1 << 1) /* About a day */
|
||||
#define VMCLOCK_FLAG_DISRUPTION_IMMINENT (1 << 2) /* About an hour */
|
||||
#define VMCLOCK_FLAG_PERIOD_ESTERROR_VALID (1 << 3)
|
||||
#define VMCLOCK_FLAG_PERIOD_MAXERROR_VALID (1 << 4)
|
||||
#define VMCLOCK_FLAG_TIME_ESTERROR_VALID (1 << 5)
|
||||
#define VMCLOCK_FLAG_TIME_MAXERROR_VALID (1 << 6)
|
||||
/*
|
||||
* If the MONOTONIC flag is set then (other than leap seconds) it is
|
||||
* guaranteed that the time calculated according this structure at
|
||||
* any given moment shall never appear to be later than the time
|
||||
* calculated via the structure at any *later* moment.
|
||||
*
|
||||
* In particular, a timestamp based on a counter reading taken
|
||||
* immediately after setting the low bit of seq_count (and the
|
||||
* associated memory barrier), using the previously-valid time and
|
||||
* period fields, shall never be later than a timestamp based on
|
||||
* a counter reading taken immediately before *clearing* the low
|
||||
* bit again after the update, using the about-to-be-valid fields.
|
||||
*/
|
||||
#define VMCLOCK_FLAG_TIME_MONOTONIC (1 << 7)
|
||||
/*
|
||||
* If the VM_GEN_COUNTER_PRESENT flag is set, the hypervisor will
|
||||
* bump the vm_generation_counter field every time the guest is
|
||||
* loaded from some save state (restored from a snapshot).
|
||||
*/
|
||||
#define VMCLOCK_FLAG_VM_GEN_COUNTER_PRESENT (1 << 8)
|
||||
/*
|
||||
* If the NOTIFICATION_PRESENT flag is set, the hypervisor will send
|
||||
* a notification every time it updates seq_count to a new even number.
|
||||
*/
|
||||
#define VMCLOCK_FLAG_NOTIFICATION_PRESENT (1 << 9)
|
||||
|
||||
uint8_t pad[2];
|
||||
uint8_t clock_status;
|
||||
#define VMCLOCK_STATUS_UNKNOWN 0
|
||||
#define VMCLOCK_STATUS_INITIALIZING 1
|
||||
#define VMCLOCK_STATUS_SYNCHRONIZED 2
|
||||
#define VMCLOCK_STATUS_FREERUNNING 3
|
||||
#define VMCLOCK_STATUS_UNRELIABLE 4
|
||||
|
||||
/*
|
||||
* The time exposed through this device is never smeared. This field
|
||||
* corresponds to the 'subtype' field in virtio-rtc, which indicates
|
||||
* the smearing method. However in this case it provides a *hint* to
|
||||
* the guest operating system, such that *if* the guest OS wants to
|
||||
* provide its users with an alternative clock which does not follow
|
||||
* UTC, it may do so in a fashion consistent with the other systems
|
||||
* in the nearby environment.
|
||||
*/
|
||||
uint8_t leap_second_smearing_hint; /* Matches VIRTIO_RTC_SUBTYPE_xxx */
|
||||
#define VMCLOCK_SMEARING_STRICT 0
|
||||
#define VMCLOCK_SMEARING_NOON_LINEAR 1
|
||||
#define VMCLOCK_SMEARING_UTC_SLS 2
|
||||
uint16_t tai_offset_sec; /* Actually two's complement signed */
|
||||
uint8_t leap_indicator;
|
||||
/*
|
||||
* This field is based on the VIRTIO_RTC_LEAP_xxx values as defined
|
||||
* in the current draft of virtio-rtc, but since smearing cannot be
|
||||
* used with the shared memory device, some values are not used.
|
||||
*
|
||||
* The _POST_POS and _POST_NEG values allow the guest to perform
|
||||
* its own smearing during the day or so after a leap second when
|
||||
* such smearing may need to continue being applied for a leap
|
||||
* second which is now theoretically "historical".
|
||||
*/
|
||||
#define VMCLOCK_LEAP_NONE 0x00 /* No known nearby leap second */
|
||||
#define VMCLOCK_LEAP_PRE_POS 0x01 /* Positive leap second at EOM */
|
||||
#define VMCLOCK_LEAP_PRE_NEG 0x02 /* Negative leap second at EOM */
|
||||
#define VMCLOCK_LEAP_POS 0x03 /* Set during 23:59:60 second */
|
||||
#define VMCLOCK_LEAP_POST_POS 0x04
|
||||
#define VMCLOCK_LEAP_POST_NEG 0x05
|
||||
|
||||
/* Bit shift for counter_period_frac_sec and its error rate */
|
||||
uint8_t counter_period_shift;
|
||||
/*
|
||||
* Paired values of counter and UTC at a given point in time.
|
||||
*/
|
||||
uint64_t counter_value;
|
||||
/*
|
||||
* Counter period, and error margin of same. The unit of these
|
||||
* fields is 1/2^(64 + counter_period_shift) of a second.
|
||||
*/
|
||||
uint64_t counter_period_frac_sec;
|
||||
uint64_t counter_period_esterror_rate_frac_sec;
|
||||
uint64_t counter_period_maxerror_rate_frac_sec;
|
||||
|
||||
/*
|
||||
* Time according to time_type field above.
|
||||
*/
|
||||
uint64_t time_sec; /* Seconds since time_type epoch */
|
||||
uint64_t time_frac_sec; /* Units of 1/2^64 of a second */
|
||||
uint64_t time_esterror_nanosec;
|
||||
uint64_t time_maxerror_nanosec;
|
||||
|
||||
/*
|
||||
* This field changes to another non-repeating value when the guest
|
||||
* has been loaded from a snapshot. In addition to handling a
|
||||
* disruption in time (which will also be signalled through the
|
||||
* disruption_marker field), a guest may wish to discard UUIDs,
|
||||
* reset network connections, reseed entropy, etc.
|
||||
*/
|
||||
uint64_t vm_generation_counter;
|
||||
};
|
||||
|
||||
#endif /* __VMCLOCK_ABI_H__ */
|
||||
Reference in new issue
Block a user