diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/vhost/vhost.h | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/vhost/vhost.h')
-rw-r--r-- | drivers/vhost/vhost.h | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index afd77295971c..8e03379dd30f 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h | |||
@@ -15,11 +15,6 @@ | |||
15 | 15 | ||
16 | struct vhost_device; | 16 | struct vhost_device; |
17 | 17 | ||
18 | enum { | ||
19 | /* Enough place for all fragments, head, and virtio net header. */ | ||
20 | VHOST_NET_MAX_SG = MAX_SKB_FRAGS + 2, | ||
21 | }; | ||
22 | |||
23 | struct vhost_work; | 18 | struct vhost_work; |
24 | typedef void (*vhost_work_fn_t)(struct vhost_work *work); | 19 | typedef void (*vhost_work_fn_t)(struct vhost_work *work); |
25 | 20 | ||
@@ -89,34 +84,43 @@ struct vhost_virtqueue { | |||
89 | /* Used flags */ | 84 | /* Used flags */ |
90 | u16 used_flags; | 85 | u16 used_flags; |
91 | 86 | ||
87 | /* Last used index value we have signalled on */ | ||
88 | u16 signalled_used; | ||
89 | |||
90 | /* Last used index value we have signalled on */ | ||
91 | bool signalled_used_valid; | ||
92 | |||
92 | /* Log writes to used structure. */ | 93 | /* Log writes to used structure. */ |
93 | bool log_used; | 94 | bool log_used; |
94 | u64 log_addr; | 95 | u64 log_addr; |
95 | 96 | ||
96 | struct iovec indirect[VHOST_NET_MAX_SG]; | 97 | struct iovec iov[UIO_MAXIOV]; |
97 | struct iovec iov[VHOST_NET_MAX_SG]; | 98 | /* hdr is used to store the virtio header. |
98 | struct iovec hdr[VHOST_NET_MAX_SG]; | 99 | * Since each iovec has >= 1 byte length, we never need more than |
100 | * header length entries to store the header. */ | ||
101 | struct iovec hdr[sizeof(struct virtio_net_hdr_mrg_rxbuf)]; | ||
102 | struct iovec *indirect; | ||
99 | size_t vhost_hlen; | 103 | size_t vhost_hlen; |
100 | size_t sock_hlen; | 104 | size_t sock_hlen; |
101 | struct vring_used_elem heads[VHOST_NET_MAX_SG]; | 105 | struct vring_used_elem *heads; |
102 | /* We use a kind of RCU to access private pointer. | 106 | /* We use a kind of RCU to access private pointer. |
103 | * All readers access it from worker, which makes it possible to | 107 | * All readers access it from worker, which makes it possible to |
104 | * flush the vhost_work instead of synchronize_rcu. Therefore readers do | 108 | * flush the vhost_work instead of synchronize_rcu. Therefore readers do |
105 | * not need to call rcu_read_lock/rcu_read_unlock: the beginning of | 109 | * not need to call rcu_read_lock/rcu_read_unlock: the beginning of |
106 | * vhost_work execution acts instead of rcu_read_lock() and the end of | 110 | * vhost_work execution acts instead of rcu_read_lock() and the end of |
107 | * vhost_work execution acts instead of rcu_read_lock(). | 111 | * vhost_work execution acts instead of rcu_read_unlock(). |
108 | * Writers use virtqueue mutex. */ | 112 | * Writers use virtqueue mutex. */ |
109 | void *private_data; | 113 | void __rcu *private_data; |
110 | /* Log write descriptors */ | 114 | /* Log write descriptors */ |
111 | void __user *log_base; | 115 | void __user *log_base; |
112 | struct vhost_log log[VHOST_NET_MAX_SG]; | 116 | struct vhost_log *log; |
113 | }; | 117 | }; |
114 | 118 | ||
115 | struct vhost_dev { | 119 | struct vhost_dev { |
116 | /* Readers use RCU to access memory table pointer | 120 | /* Readers use RCU to access memory table pointer |
117 | * log base pointer and features. | 121 | * log base pointer and features. |
118 | * Writers use mutex below.*/ | 122 | * Writers use mutex below.*/ |
119 | struct vhost_memory *memory; | 123 | struct vhost_memory __rcu *memory; |
120 | struct mm_struct *mm; | 124 | struct mm_struct *mm; |
121 | struct mutex mutex; | 125 | struct mutex mutex; |
122 | unsigned acked_features; | 126 | unsigned acked_features; |
@@ -151,8 +155,8 @@ void vhost_add_used_and_signal(struct vhost_dev *, struct vhost_virtqueue *, | |||
151 | void vhost_add_used_and_signal_n(struct vhost_dev *, struct vhost_virtqueue *, | 155 | void vhost_add_used_and_signal_n(struct vhost_dev *, struct vhost_virtqueue *, |
152 | struct vring_used_elem *heads, unsigned count); | 156 | struct vring_used_elem *heads, unsigned count); |
153 | void vhost_signal(struct vhost_dev *, struct vhost_virtqueue *); | 157 | void vhost_signal(struct vhost_dev *, struct vhost_virtqueue *); |
154 | void vhost_disable_notify(struct vhost_virtqueue *); | 158 | void vhost_disable_notify(struct vhost_dev *, struct vhost_virtqueue *); |
155 | bool vhost_enable_notify(struct vhost_virtqueue *); | 159 | bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *); |
156 | 160 | ||
157 | int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log, | 161 | int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log, |
158 | unsigned int log_num, u64 len); | 162 | unsigned int log_num, u64 len); |
@@ -164,16 +168,21 @@ int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log, | |||
164 | } while (0) | 168 | } while (0) |
165 | 169 | ||
166 | enum { | 170 | enum { |
167 | VHOST_FEATURES = (1 << VIRTIO_F_NOTIFY_ON_EMPTY) | | 171 | VHOST_FEATURES = (1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | |
168 | (1 << VIRTIO_RING_F_INDIRECT_DESC) | | 172 | (1ULL << VIRTIO_RING_F_INDIRECT_DESC) | |
169 | (1 << VHOST_F_LOG_ALL) | | 173 | (1ULL << VIRTIO_RING_F_EVENT_IDX) | |
170 | (1 << VHOST_NET_F_VIRTIO_NET_HDR) | | 174 | (1ULL << VHOST_F_LOG_ALL) | |
171 | (1 << VIRTIO_NET_F_MRG_RXBUF), | 175 | (1ULL << VHOST_NET_F_VIRTIO_NET_HDR) | |
176 | (1ULL << VIRTIO_NET_F_MRG_RXBUF), | ||
172 | }; | 177 | }; |
173 | 178 | ||
174 | static inline int vhost_has_feature(struct vhost_dev *dev, int bit) | 179 | static inline int vhost_has_feature(struct vhost_dev *dev, int bit) |
175 | { | 180 | { |
176 | unsigned acked_features = rcu_dereference(dev->acked_features); | 181 | unsigned acked_features; |
182 | |||
183 | /* TODO: check that we are running from vhost_worker or dev mutex is | ||
184 | * held? */ | ||
185 | acked_features = rcu_dereference_index_check(dev->acked_features, 1); | ||
177 | return acked_features & (1 << bit); | 186 | return acked_features & (1 << bit); |
178 | } | 187 | } |
179 | 188 | ||