aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/lguest_launcher.h9
-rw-r--r--include/linux/skbuff.h1
-rw-r--r--include/linux/virtio.h19
-rw-r--r--include/linux/virtio_balloon.h18
-rw-r--r--include/linux/virtio_blk.h22
-rw-r--r--include/linux/virtio_config.h104
-rw-r--r--include/linux/virtio_net.h32
-rw-r--r--include/linux/virtio_pci.h57
-rw-r--r--include/linux/virtio_ring.h14
9 files changed, 180 insertions, 96 deletions
diff --git a/include/linux/lguest_launcher.h b/include/linux/lguest_launcher.h
index 697104da91f1..589be3e1f3ac 100644
--- a/include/linux/lguest_launcher.h
+++ b/include/linux/lguest_launcher.h
@@ -23,7 +23,12 @@
23struct lguest_device_desc { 23struct lguest_device_desc {
24 /* The device type: console, network, disk etc. Type 0 terminates. */ 24 /* The device type: console, network, disk etc. Type 0 terminates. */
25 __u8 type; 25 __u8 type;
26 /* The number of bytes of the config array. */ 26 /* The number of virtqueues (first in config array) */
27 __u8 num_vq;
28 /* The number of bytes of feature bits. Multiply by 2: one for host
29 * features and one for guest acknowledgements. */
30 __u8 feature_len;
31 /* The number of bytes of the config array after virtqueues. */
27 __u8 config_len; 32 __u8 config_len;
28 /* A status byte, written by the Guest. */ 33 /* A status byte, written by the Guest. */
29 __u8 status; 34 __u8 status;
@@ -31,7 +36,7 @@ struct lguest_device_desc {
31}; 36};
32 37
33/*D:135 This is how we expect the device configuration field for a virtqueue 38/*D:135 This is how we expect the device configuration field for a virtqueue
34 * (type VIRTIO_CONFIG_F_VIRTQUEUE) to be laid out: */ 39 * to be laid out in config space. */
35struct lguest_vqconfig { 40struct lguest_vqconfig {
36 /* The number of entries in the virtio_ring */ 41 /* The number of entries in the virtio_ring */
37 __u16 num; 42 __u16 num;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index dfe975a9967e..412672a79e8a 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1810,5 +1810,6 @@ static inline void skb_forward_csum(struct sk_buff *skb)
1810 skb->ip_summed = CHECKSUM_NONE; 1810 skb->ip_summed = CHECKSUM_NONE;
1811} 1811}
1812 1812
1813bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off);
1813#endif /* __KERNEL__ */ 1814#endif /* __KERNEL__ */
1814#endif /* _LINUX_SKBUFF_H */ 1815#endif /* _LINUX_SKBUFF_H */
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 14e1379876d3..260d1fcf29a4 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -11,15 +11,13 @@
11/** 11/**
12 * virtqueue - a queue to register buffers for sending or receiving. 12 * virtqueue - a queue to register buffers for sending or receiving.
13 * @callback: the function to call when buffers are consumed (can be NULL). 13 * @callback: the function to call when buffers are consumed (can be NULL).
14 * If this returns false, callbacks are suppressed until vq_ops->restart
15 * is called.
16 * @vdev: the virtio device this queue was created for. 14 * @vdev: the virtio device this queue was created for.
17 * @vq_ops: the operations for this virtqueue (see below). 15 * @vq_ops: the operations for this virtqueue (see below).
18 * @priv: a pointer for the virtqueue implementation to use. 16 * @priv: a pointer for the virtqueue implementation to use.
19 */ 17 */
20struct virtqueue 18struct virtqueue
21{ 19{
22 bool (*callback)(struct virtqueue *vq); 20 void (*callback)(struct virtqueue *vq);
23 struct virtio_device *vdev; 21 struct virtio_device *vdev;
24 struct virtqueue_ops *vq_ops; 22 struct virtqueue_ops *vq_ops;
25 void *priv; 23 void *priv;
@@ -41,13 +39,12 @@ struct virtqueue
41 * vq: the struct virtqueue we're talking about. 39 * vq: the struct virtqueue we're talking about.
42 * len: the length written into the buffer 40 * len: the length written into the buffer
43 * Returns NULL or the "data" token handed to add_buf. 41 * Returns NULL or the "data" token handed to add_buf.
44 * @restart: restart callbacks after callback returned false. 42 * @disable_cb: disable callbacks
43 * vq: the struct virtqueue we're talking about.
44 * @enable_cb: restart callbacks after disable_cb.
45 * vq: the struct virtqueue we're talking about. 45 * vq: the struct virtqueue we're talking about.
46 * This returns "false" (and doesn't re-enable) if there are pending 46 * This returns "false" (and doesn't re-enable) if there are pending
47 * buffers in the queue, to avoid a race. 47 * buffers in the queue, to avoid a race.
48 * @shutdown: "unadd" all buffers.
49 * vq: the struct virtqueue we're talking about.
50 * Remove everything from the queue.
51 * 48 *
52 * Locking rules are straightforward: the driver is responsible for 49 * Locking rules are straightforward: the driver is responsible for
53 * locking. No two operations may be invoked simultaneously. 50 * locking. No two operations may be invoked simultaneously.
@@ -65,9 +62,8 @@ struct virtqueue_ops {
65 62
66 void *(*get_buf)(struct virtqueue *vq, unsigned int *len); 63 void *(*get_buf)(struct virtqueue *vq, unsigned int *len);
67 64
68 bool (*restart)(struct virtqueue *vq); 65 void (*disable_cb)(struct virtqueue *vq);
69 66 bool (*enable_cb)(struct virtqueue *vq);
70 void (*shutdown)(struct virtqueue *vq);
71}; 67};
72 68
73/** 69/**
@@ -97,12 +93,15 @@ void unregister_virtio_device(struct virtio_device *dev);
97 * @probe: the function to call when a device is found. Returns a token for 93 * @probe: the function to call when a device is found. Returns a token for
98 * remove, or PTR_ERR(). 94 * remove, or PTR_ERR().
99 * @remove: the function when a device is removed. 95 * @remove: the function when a device is removed.
96 * @config_changed: optional function to call when the device configuration
97 * changes; may be called in interrupt context.
100 */ 98 */
101struct virtio_driver { 99struct virtio_driver {
102 struct device_driver driver; 100 struct device_driver driver;
103 const struct virtio_device_id *id_table; 101 const struct virtio_device_id *id_table;
104 int (*probe)(struct virtio_device *dev); 102 int (*probe)(struct virtio_device *dev);
105 void (*remove)(struct virtio_device *dev); 103 void (*remove)(struct virtio_device *dev);
104 void (*config_changed)(struct virtio_device *dev);
106}; 105};
107 106
108int register_virtio_driver(struct virtio_driver *drv); 107int register_virtio_driver(struct virtio_driver *drv);
diff --git a/include/linux/virtio_balloon.h b/include/linux/virtio_balloon.h
new file mode 100644
index 000000000000..979524ee75b7
--- /dev/null
+++ b/include/linux/virtio_balloon.h
@@ -0,0 +1,18 @@
1#ifndef _LINUX_VIRTIO_BALLOON_H
2#define _LINUX_VIRTIO_BALLOON_H
3#include <linux/virtio_config.h>
4
5/* The ID for virtio_balloon */
6#define VIRTIO_ID_BALLOON 5
7
8/* The feature bitmap for virtio balloon */
9#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */
10
11struct virtio_balloon_config
12{
13 /* Number of pages host wants Guest to give up. */
14 __le32 num_pages;
15 /* Number of pages we've actually got in balloon. */
16 __le32 actual;
17};
18#endif /* _LINUX_VIRTIO_BALLOON_H */
diff --git a/include/linux/virtio_blk.h b/include/linux/virtio_blk.h
index 7bd2bce0cfd9..bca0b10d7947 100644
--- a/include/linux/virtio_blk.h
+++ b/include/linux/virtio_blk.h
@@ -6,15 +6,19 @@
6#define VIRTIO_ID_BLOCK 2 6#define VIRTIO_ID_BLOCK 2
7 7
8/* Feature bits */ 8/* Feature bits */
9#define VIRTIO_CONFIG_BLK_F 0x40 9#define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */
10#define VIRTIO_BLK_F_BARRIER 1 /* Does host support barriers? */ 10#define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */
11#define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
11 12
12/* The capacity (in 512-byte sectors). */ 13struct virtio_blk_config
13#define VIRTIO_CONFIG_BLK_F_CAPACITY 0x41 14{
14/* The maximum segment size. */ 15 /* The capacity (in 512-byte sectors). */
15#define VIRTIO_CONFIG_BLK_F_SIZE_MAX 0x42 16 __le64 capacity;
16/* The maximum number of segments. */ 17 /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
17#define VIRTIO_CONFIG_BLK_F_SEG_MAX 0x43 18 __le32 size_max;
19 /* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */
20 __le32 seg_max;
21} __attribute__((packed));
18 22
19/* These two define direction. */ 23/* These two define direction. */
20#define VIRTIO_BLK_T_IN 0 24#define VIRTIO_BLK_T_IN 0
@@ -35,8 +39,6 @@ struct virtio_blk_outhdr
35 __u32 ioprio; 39 __u32 ioprio;
36 /* Sector (ie. 512 byte offset) */ 40 /* Sector (ie. 512 byte offset) */
37 __u64 sector; 41 __u64 sector;
38 /* Where to put reply. */
39 __u64 id;
40}; 42};
41 43
42#define VIRTIO_BLK_S_OK 0 44#define VIRTIO_BLK_S_OK 0
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index bcc01888df78..d581b2914b34 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -5,7 +5,7 @@
5 * store and access that space differently. */ 5 * store and access that space differently. */
6#include <linux/types.h> 6#include <linux/types.h>
7 7
8/* Status byte for guest to report progress, and synchronize config. */ 8/* Status byte for guest to report progress, and synchronize features. */
9/* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */ 9/* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */
10#define VIRTIO_CONFIG_S_ACKNOWLEDGE 1 10#define VIRTIO_CONFIG_S_ACKNOWLEDGE 1
11/* We have found a driver for the device. */ 11/* We have found a driver for the device. */
@@ -15,34 +15,27 @@
15/* We've given up on this device. */ 15/* We've given up on this device. */
16#define VIRTIO_CONFIG_S_FAILED 0x80 16#define VIRTIO_CONFIG_S_FAILED 0x80
17 17
18/* Feature byte (actually 7 bits availabe): */
19/* Requirements/features of the virtio implementation. */
20#define VIRTIO_CONFIG_F_VIRTIO 1
21/* Requirements/features of the virtqueue (may have more than one). */
22#define VIRTIO_CONFIG_F_VIRTQUEUE 2
23
24#ifdef __KERNEL__ 18#ifdef __KERNEL__
25struct virtio_device; 19struct virtio_device;
26 20
27/** 21/**
28 * virtio_config_ops - operations for configuring a virtio device 22 * virtio_config_ops - operations for configuring a virtio device
29 * @find: search for the next configuration field of the given type. 23 * @feature: search for a feature in this config
30 * vdev: the virtio_device 24 * vdev: the virtio_device
31 * type: the feature type 25 * bit: the feature bit
32 * len: the (returned) length of the field if found. 26 * Returns true if the feature is supported. Acknowledges the feature
33 * Returns a token if found, or NULL. Never returnes the same field twice 27 * so the host can see it.
34 * (ie. it's used up). 28 * @get: read the value of a configuration field
35 * @get: read the value of a configuration field after find().
36 * vdev: the virtio_device 29 * vdev: the virtio_device
37 * token: the token returned from find(). 30 * offset: the offset of the configuration field
38 * buf: the buffer to write the field value into. 31 * buf: the buffer to write the field value into.
39 * len: the length of the buffer (given by find()). 32 * len: the length of the buffer
40 * Note that contents are conventionally little-endian. 33 * Note that contents are conventionally little-endian.
41 * @set: write the value of a configuration field after find(). 34 * @set: write the value of a configuration field
42 * vdev: the virtio_device 35 * vdev: the virtio_device
43 * token: the token returned from find(). 36 * offset: the offset of the configuration field
44 * buf: the buffer to read the field value from. 37 * buf: the buffer to read the field value from.
45 * len: the length of the buffer (given by find()). 38 * len: the length of the buffer
46 * Note that contents are conventionally little-endian. 39 * Note that contents are conventionally little-endian.
47 * @get_status: read the status byte 40 * @get_status: read the status byte
48 * vdev: the virtio_device 41 * vdev: the virtio_device
@@ -50,62 +43,67 @@ struct virtio_device;
50 * @set_status: write the status byte 43 * @set_status: write the status byte
51 * vdev: the virtio_device 44 * vdev: the virtio_device
52 * status: the new status byte 45 * status: the new status byte
53 * @find_vq: find the first VIRTIO_CONFIG_F_VIRTQUEUE and create a virtqueue. 46 * @reset: reset the device
47 * vdev: the virtio device
48 * After this, status and feature negotiation must be done again
49 * @find_vq: find a virtqueue and instantiate it.
54 * vdev: the virtio_device 50 * vdev: the virtio_device
51 * index: the 0-based virtqueue number in case there's more than one.
55 * callback: the virqtueue callback 52 * callback: the virqtueue callback
56 * Returns the new virtqueue or ERR_PTR(). 53 * Returns the new virtqueue or ERR_PTR() (eg. -ENOENT).
57 * @del_vq: free a virtqueue found by find_vq(). 54 * @del_vq: free a virtqueue found by find_vq().
58 */ 55 */
59struct virtio_config_ops 56struct virtio_config_ops
60{ 57{
61 void *(*find)(struct virtio_device *vdev, u8 type, unsigned *len); 58 bool (*feature)(struct virtio_device *vdev, unsigned bit);
62 void (*get)(struct virtio_device *vdev, void *token, 59 void (*get)(struct virtio_device *vdev, unsigned offset,
63 void *buf, unsigned len); 60 void *buf, unsigned len);
64 void (*set)(struct virtio_device *vdev, void *token, 61 void (*set)(struct virtio_device *vdev, unsigned offset,
65 const void *buf, unsigned len); 62 const void *buf, unsigned len);
66 u8 (*get_status)(struct virtio_device *vdev); 63 u8 (*get_status)(struct virtio_device *vdev);
67 void (*set_status)(struct virtio_device *vdev, u8 status); 64 void (*set_status)(struct virtio_device *vdev, u8 status);
65 void (*reset)(struct virtio_device *vdev);
68 struct virtqueue *(*find_vq)(struct virtio_device *vdev, 66 struct virtqueue *(*find_vq)(struct virtio_device *vdev,
69 bool (*callback)(struct virtqueue *)); 67 unsigned index,
68 void (*callback)(struct virtqueue *));
70 void (*del_vq)(struct virtqueue *vq); 69 void (*del_vq)(struct virtqueue *vq);
71}; 70};
72 71
73/** 72/**
74 * virtio_config_val - get a single virtio config and mark it used. 73 * virtio_config_val - look for a feature and get a single virtio config.
75 * @config: the virtio config space 74 * @vdev: the virtio device
76 * @type: the type to search for. 75 * @fbit: the feature bit
76 * @offset: the type to search for.
77 * @val: a pointer to the value to fill in. 77 * @val: a pointer to the value to fill in.
78 * 78 *
79 * Once used, the config type is marked with VIRTIO_CONFIG_F_USED so it can't 79 * The return value is -ENOENT if the feature doesn't exist. Otherwise
80 * be found again. This version does endian conversion. */ 80 * the value is endian-corrected and returned in v. */
81#define virtio_config_val(vdev, type, v) ({ \ 81#define virtio_config_val(vdev, fbit, offset, v) ({ \
82 int _err = __virtio_config_val((vdev),(type),(v),sizeof(*(v))); \ 82 int _err; \
83 \ 83 if ((vdev)->config->feature((vdev), (fbit))) { \
84 BUILD_BUG_ON(sizeof(*(v)) != 1 && sizeof(*(v)) != 2 \ 84 __virtio_config_val((vdev), (offset), (v)); \
85 && sizeof(*(v)) != 4 && sizeof(*(v)) != 8); \ 85 _err = 0; \
86 if (!_err) { \ 86 } else \
87 switch (sizeof(*(v))) { \ 87 _err = -ENOENT; \
88 case 2: le16_to_cpus((__u16 *) v); break; \
89 case 4: le32_to_cpus((__u32 *) v); break; \
90 case 8: le64_to_cpus((__u64 *) v); break; \
91 } \
92 } \
93 _err; \ 88 _err; \
94}) 89})
95 90
96int __virtio_config_val(struct virtio_device *dev,
97 u8 type, void *val, size_t size);
98
99/** 91/**
100 * virtio_use_bit - helper to use a feature bit in a bitfield value. 92 * __virtio_config_val - get a single virtio config without feature check.
101 * @dev: the virtio device 93 * @vdev: the virtio device
102 * @token: the token as returned from vdev->config->find(). 94 * @offset: the type to search for.
103 * @len: the length of the field. 95 * @val: a pointer to the value to fill in.
104 * @bitnum: the bit to test.
105 * 96 *
106 * If handed a NULL token, it returns false, otherwise returns bit status. 97 * The value is endian-corrected and returned in v. */
107 * If it's one, it sets the mirroring acknowledgement bit. */ 98#define __virtio_config_val(vdev, offset, v) do { \
108int virtio_use_bit(struct virtio_device *vdev, 99 BUILD_BUG_ON(sizeof(*(v)) != 1 && sizeof(*(v)) != 2 \
109 void *token, unsigned int len, unsigned int bitnum); 100 && sizeof(*(v)) != 4 && sizeof(*(v)) != 8); \
101 (vdev)->config->get((vdev), (offset), (v), sizeof(*(v))); \
102 switch (sizeof(*(v))) { \
103 case 2: le16_to_cpus((__u16 *) v); break; \
104 case 4: le32_to_cpus((__u32 *) v); break; \
105 case 8: le64_to_cpus((__u64 *) v); break; \
106 } \
107} while(0)
110#endif /* __KERNEL__ */ 108#endif /* __KERNEL__ */
111#endif /* _LINUX_VIRTIO_CONFIG_H */ 109#endif /* _LINUX_VIRTIO_CONFIG_H */
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index ae469ae55d36..1ea3351df609 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -5,32 +5,32 @@
5/* The ID for virtio_net */ 5/* The ID for virtio_net */
6#define VIRTIO_ID_NET 1 6#define VIRTIO_ID_NET 1
7 7
8/* The bitmap of config for virtio net */ 8/* The feature bitmap for virtio net */
9#define VIRTIO_CONFIG_NET_F 0x40 9#define VIRTIO_NET_F_CSUM 0 /* Can handle pkts w/ partial csum */
10#define VIRTIO_NET_F_NO_CSUM 0 10#define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */
11#define VIRTIO_NET_F_TSO4 1 11#define VIRTIO_NET_F_GSO 6 /* Can handle pkts w/ any GSO type */
12#define VIRTIO_NET_F_UFO 2
13#define VIRTIO_NET_F_TSO4_ECN 3
14#define VIRTIO_NET_F_TSO6 4
15 12
16/* The config defining mac address. */ 13struct virtio_net_config
17#define VIRTIO_CONFIG_NET_MAC_F 0x41 14{
15 /* The config defining mac address (if VIRTIO_NET_F_MAC) */
16 __u8 mac[6];
17} __attribute__((packed));
18 18
19/* This is the first element of the scatter-gather list. If you don't 19/* This is the first element of the scatter-gather list. If you don't
20 * specify GSO or CSUM features, you can simply ignore the header. */ 20 * specify GSO or CSUM features, you can simply ignore the header. */
21struct virtio_net_hdr 21struct virtio_net_hdr
22{ 22{
23#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 // Use csum_start, csum_offset 23#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 // Use csum_start, csum_offset
24 __u8 flags; 24 __u8 flags;
25#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame 25#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame
26#define VIRTIO_NET_HDR_GSO_TCPV4 1 // GSO frame, IPv4 TCP (TSO) 26#define VIRTIO_NET_HDR_GSO_TCPV4 1 // GSO frame, IPv4 TCP (TSO)
27/* FIXME: Do we need this? If they said they can handle ECN, do they care? */
28#define VIRTIO_NET_HDR_GSO_TCPV4_ECN 2 // GSO frame, IPv4 TCP w/ ECN
29#define VIRTIO_NET_HDR_GSO_UDP 3 // GSO frame, IPv4 UDP (UFO) 27#define VIRTIO_NET_HDR_GSO_UDP 3 // GSO frame, IPv4 UDP (UFO)
30#define VIRTIO_NET_HDR_GSO_TCPV6 4 // GSO frame, IPv6 TCP 28#define VIRTIO_NET_HDR_GSO_TCPV6 4 // GSO frame, IPv6 TCP
31 __u8 gso_type; 29#define VIRTIO_NET_HDR_GSO_ECN 0x80 // TCP has ECN set
32 __u16 gso_size; 30 __u8 gso_type;
33 __u16 csum_start; 31 __u16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */
34 __u16 csum_offset; 32 __u16 gso_size; /* Bytes to append to gso_hdr_len per frame */
33 __u16 csum_start; /* Position to start checksumming from */
34 __u16 csum_offset; /* Offset after that to place checksum */
35}; 35};
36#endif /* _LINUX_VIRTIO_NET_H */ 36#endif /* _LINUX_VIRTIO_NET_H */
diff --git a/include/linux/virtio_pci.h b/include/linux/virtio_pci.h
new file mode 100644
index 000000000000..b3151659cf49
--- /dev/null
+++ b/include/linux/virtio_pci.h
@@ -0,0 +1,57 @@
1/*
2 * Virtio PCI driver
3 *
4 * This module allows virtio devices to be used over a virtual PCI device.
5 * This can be used with QEMU based VMMs like KVM or Xen.
6 *
7 * Copyright IBM Corp. 2007
8 *
9 * Authors:
10 * Anthony Liguori <aliguori@us.ibm.com>
11 *
12 * This work is licensed under the terms of the GNU GPL, version 2 or later.
13 * See the COPYING file in the top-level directory.
14 *
15 */
16
17#ifndef _LINUX_VIRTIO_PCI_H
18#define _LINUX_VIRTIO_PCI_H
19
20#include <linux/virtio_config.h>
21
22/* A 32-bit r/o bitmask of the features supported by the host */
23#define VIRTIO_PCI_HOST_FEATURES 0
24
25/* A 32-bit r/w bitmask of features activated by the guest */
26#define VIRTIO_PCI_GUEST_FEATURES 4
27
28/* A 32-bit r/w PFN for the currently selected queue */
29#define VIRTIO_PCI_QUEUE_PFN 8
30
31/* A 16-bit r/o queue size for the currently selected queue */
32#define VIRTIO_PCI_QUEUE_NUM 12
33
34/* A 16-bit r/w queue selector */
35#define VIRTIO_PCI_QUEUE_SEL 14
36
37/* A 16-bit r/w queue notifier */
38#define VIRTIO_PCI_QUEUE_NOTIFY 16
39
40/* An 8-bit device status register. */
41#define VIRTIO_PCI_STATUS 18
42
43/* An 8-bit r/o interrupt status register. Reading the value will return the
44 * current contents of the ISR and will also clear it. This is effectively
45 * a read-and-acknowledge. */
46#define VIRTIO_PCI_ISR 19
47
48/* The bit of the ISR which indicates a device configuration change. */
49#define VIRTIO_PCI_ISR_CONFIG 0x2
50
51/* The remaining space is defined by each driver as the per-driver
52 * configuration space */
53#define VIRTIO_PCI_CONFIG 20
54
55/* Virtio ABI version, this must match exactly */
56#define VIRTIO_PCI_ABI_VERSION 0
57#endif
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index 1a4ed49f6478..abe481ed990e 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -15,9 +15,13 @@
15/* This marks a buffer as write-only (otherwise read-only). */ 15/* This marks a buffer as write-only (otherwise read-only). */
16#define VRING_DESC_F_WRITE 2 16#define VRING_DESC_F_WRITE 2
17 17
18/* This means don't notify other side when buffer added. */ 18/* The Host uses this in used->flags to advise the Guest: don't kick me when
19 * you add a buffer. It's unreliable, so it's simply an optimization. Guest
20 * will still kick if it's out of buffers. */
19#define VRING_USED_F_NO_NOTIFY 1 21#define VRING_USED_F_NO_NOTIFY 1
20/* This means don't interrupt guest when buffer consumed. */ 22/* The Guest uses this in avail->flags to advise the Host: don't interrupt me
23 * when you consume a buffer. It's unreliable, so it's simply an
24 * optimization. */
21#define VRING_AVAIL_F_NO_INTERRUPT 1 25#define VRING_AVAIL_F_NO_INTERRUPT 1
22 26
23/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */ 27/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */
@@ -89,7 +93,7 @@ struct vring {
89 * }; 93 * };
90 */ 94 */
91static inline void vring_init(struct vring *vr, unsigned int num, void *p, 95static inline void vring_init(struct vring *vr, unsigned int num, void *p,
92 unsigned int pagesize) 96 unsigned long pagesize)
93{ 97{
94 vr->num = num; 98 vr->num = num;
95 vr->desc = p; 99 vr->desc = p;
@@ -98,7 +102,7 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
98 & ~(pagesize - 1)); 102 & ~(pagesize - 1));
99} 103}
100 104
101static inline unsigned vring_size(unsigned int num, unsigned int pagesize) 105static inline unsigned vring_size(unsigned int num, unsigned long pagesize)
102{ 106{
103 return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num) 107 return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)
104 + pagesize - 1) & ~(pagesize - 1)) 108 + pagesize - 1) & ~(pagesize - 1))
@@ -114,7 +118,7 @@ struct virtqueue *vring_new_virtqueue(unsigned int num,
114 struct virtio_device *vdev, 118 struct virtio_device *vdev,
115 void *pages, 119 void *pages,
116 void (*notify)(struct virtqueue *vq), 120 void (*notify)(struct virtqueue *vq),
117 bool (*callback)(struct virtqueue *vq)); 121 void (*callback)(struct virtqueue *vq));
118void vring_del_virtqueue(struct virtqueue *vq); 122void vring_del_virtqueue(struct virtqueue *vq);
119 123
120irqreturn_t vring_interrupt(int irq, void *_vq); 124irqreturn_t vring_interrupt(int irq, void *_vq);