blob: cc2f73e03475b620053765b373c8b1a39fc08762 [file] [log] [blame]
Rusty Russell0a8a69d2007-10-22 11:03:40 +10001/* Virtio ring implementation.
2 *
3 * Copyright 2007 Rusty Russell IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19#include <linux/virtio.h>
20#include <linux/virtio_ring.h>
Rusty Russelle34f8722008-07-25 12:06:13 -050021#include <linux/virtio_config.h>
Rusty Russell0a8a69d2007-10-22 11:03:40 +100022#include <linux/device.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090023#include <linux/slab.h>
Rusty Russell0a8a69d2007-10-22 11:03:40 +100024
Michael S. Tsirkind57ed952010-01-28 00:42:23 +020025/* virtio guest is communicating with a virtual "device" that actually runs on
26 * a host processor. Memory barriers are used to control SMP effects. */
27#ifdef CONFIG_SMP
28/* Where possible, use SMP barriers which are more lightweight than mandatory
29 * barriers, because mandatory barriers control MMIO effects on accesses
30 * through relaxed memory I/O windows (which virtio does not use). */
31#define virtio_mb() smp_mb()
32#define virtio_rmb() smp_rmb()
33#define virtio_wmb() smp_wmb()
34#else
35/* We must force memory ordering even if guest is UP since host could be
36 * running on another CPU, but SMP barriers are defined to barrier() in that
37 * configuration. So fall back to mandatory barriers instead. */
38#define virtio_mb() mb()
39#define virtio_rmb() rmb()
40#define virtio_wmb() wmb()
41#endif
42
Rusty Russell0a8a69d2007-10-22 11:03:40 +100043#ifdef DEBUG
44/* For development, we want to crash whenever the ring is screwed. */
Rusty Russell9499f5e2009-06-12 22:16:35 -060045#define BAD_RING(_vq, fmt, args...) \
46 do { \
47 dev_err(&(_vq)->vq.vdev->dev, \
48 "%s:"fmt, (_vq)->vq.name, ##args); \
49 BUG(); \
50 } while (0)
Rusty Russellc5f841f2009-03-30 21:55:22 -060051/* Caller is supposed to guarantee no reentry. */
52#define START_USE(_vq) \
53 do { \
54 if ((_vq)->in_use) \
Rusty Russell9499f5e2009-06-12 22:16:35 -060055 panic("%s:in_use = %i\n", \
56 (_vq)->vq.name, (_vq)->in_use); \
Rusty Russellc5f841f2009-03-30 21:55:22 -060057 (_vq)->in_use = __LINE__; \
Rusty Russell9499f5e2009-06-12 22:16:35 -060058 } while (0)
Roel Kluin3a35ce72009-01-22 16:42:57 +010059#define END_USE(_vq) \
Rusty Russell97a545a2010-02-24 14:22:22 -060060 do { BUG_ON(!(_vq)->in_use); (_vq)->in_use = 0; } while(0)
Rusty Russell0a8a69d2007-10-22 11:03:40 +100061#else
Rusty Russell9499f5e2009-06-12 22:16:35 -060062#define BAD_RING(_vq, fmt, args...) \
63 do { \
64 dev_err(&_vq->vq.vdev->dev, \
65 "%s:"fmt, (_vq)->vq.name, ##args); \
66 (_vq)->broken = true; \
67 } while (0)
Rusty Russell0a8a69d2007-10-22 11:03:40 +100068#define START_USE(vq)
69#define END_USE(vq)
70#endif
71
72struct vring_virtqueue
73{
74 struct virtqueue vq;
75
76 /* Actual memory layout for this queue */
77 struct vring vring;
78
79 /* Other side has made a mess, don't try any more. */
80 bool broken;
81
Mark McLoughlin9fa29b9d2009-05-11 18:11:45 +010082 /* Host supports indirect buffers */
83 bool indirect;
84
Rusty Russell0a8a69d2007-10-22 11:03:40 +100085 /* Number of free buffers */
86 unsigned int num_free;
87 /* Head of free buffer list. */
88 unsigned int free_head;
89 /* Number we've added since last sync. */
90 unsigned int num_added;
91
92 /* Last used index we've seen. */
Anthony Liguori1bc49532007-11-07 15:49:24 -060093 u16 last_used_idx;
Rusty Russell0a8a69d2007-10-22 11:03:40 +100094
95 /* How to notify other side. FIXME: commonalize hcalls! */
96 void (*notify)(struct virtqueue *vq);
97
98#ifdef DEBUG
99 /* They're supposed to lock for us. */
100 unsigned int in_use;
101#endif
102
103 /* Tokens for callbacks. */
104 void *data[];
105};
106
107#define to_vvq(_vq) container_of(_vq, struct vring_virtqueue, vq)
108
Mark McLoughlin9fa29b9d2009-05-11 18:11:45 +0100109/* Set up an indirect table of descriptors and add it to the queue. */
110static int vring_add_indirect(struct vring_virtqueue *vq,
111 struct scatterlist sg[],
112 unsigned int out,
Michael S. Tsirkinbbd603e2010-04-29 17:26:37 +0300113 unsigned int in,
114 gfp_t gfp)
Mark McLoughlin9fa29b9d2009-05-11 18:11:45 +0100115{
116 struct vring_desc *desc;
117 unsigned head;
118 int i;
119
Michael S. Tsirkinbbd603e2010-04-29 17:26:37 +0300120 desc = kmalloc((out + in) * sizeof(struct vring_desc), gfp);
Mark McLoughlin9fa29b9d2009-05-11 18:11:45 +0100121 if (!desc)
Michael S. Tsirkin686d3632010-06-10 18:16:11 +0300122 return -ENOMEM;
Mark McLoughlin9fa29b9d2009-05-11 18:11:45 +0100123
124 /* Transfer entries from the sg list into the indirect page */
125 for (i = 0; i < out; i++) {
126 desc[i].flags = VRING_DESC_F_NEXT;
127 desc[i].addr = sg_phys(sg);
128 desc[i].len = sg->length;
129 desc[i].next = i+1;
130 sg++;
131 }
132 for (; i < (out + in); i++) {
133 desc[i].flags = VRING_DESC_F_NEXT|VRING_DESC_F_WRITE;
134 desc[i].addr = sg_phys(sg);
135 desc[i].len = sg->length;
136 desc[i].next = i+1;
137 sg++;
138 }
139
140 /* Last one doesn't continue. */
141 desc[i-1].flags &= ~VRING_DESC_F_NEXT;
142 desc[i-1].next = 0;
143
144 /* We're about to use a buffer */
145 vq->num_free--;
146
147 /* Use a single buffer which doesn't continue */
148 head = vq->free_head;
149 vq->vring.desc[head].flags = VRING_DESC_F_INDIRECT;
150 vq->vring.desc[head].addr = virt_to_phys(desc);
151 vq->vring.desc[head].len = i * sizeof(struct vring_desc);
152
153 /* Update free pointer */
154 vq->free_head = vq->vring.desc[head].next;
155
156 return head;
157}
158
Michael S. Tsirkinbbd603e2010-04-29 17:26:37 +0300159int virtqueue_add_buf_gfp(struct virtqueue *_vq,
160 struct scatterlist sg[],
161 unsigned int out,
162 unsigned int in,
163 void *data,
164 gfp_t gfp)
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000165{
166 struct vring_virtqueue *vq = to_vvq(_vq);
Michael S. Tsirkin1fe9b6f2010-07-26 16:55:30 +0930167 unsigned int i, avail, uninitialized_var(prev);
168 int head;
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000169
Mark McLoughlin9fa29b9d2009-05-11 18:11:45 +0100170 START_USE(vq);
171
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000172 BUG_ON(data == NULL);
Mark McLoughlin9fa29b9d2009-05-11 18:11:45 +0100173
174 /* If the host supports indirect descriptor tables, and we have multiple
175 * buffers, then go indirect. FIXME: tune this threshold */
176 if (vq->indirect && (out + in) > 1 && vq->num_free) {
Michael S. Tsirkinbbd603e2010-04-29 17:26:37 +0300177 head = vring_add_indirect(vq, sg, out, in, gfp);
Michael S. Tsirkin1fe9b6f2010-07-26 16:55:30 +0930178 if (likely(head >= 0))
Mark McLoughlin9fa29b9d2009-05-11 18:11:45 +0100179 goto add_head;
180 }
181
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000182 BUG_ON(out + in > vq->vring.num);
183 BUG_ON(out + in == 0);
184
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000185 if (vq->num_free < out + in) {
186 pr_debug("Can't add buf len %i - avail = %i\n",
187 out + in, vq->num_free);
Rusty Russell44653ea2008-07-25 12:06:04 -0500188 /* FIXME: for historical reasons, we force a notify here if
189 * there are outgoing parts to the buffer. Presumably the
190 * host should service the ring ASAP. */
191 if (out)
192 vq->notify(&vq->vq);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000193 END_USE(vq);
194 return -ENOSPC;
195 }
196
197 /* We're about to use some buffers from the free list. */
198 vq->num_free -= out + in;
199
200 head = vq->free_head;
201 for (i = vq->free_head; out; i = vq->vring.desc[i].next, out--) {
202 vq->vring.desc[i].flags = VRING_DESC_F_NEXT;
Rusty Russell15f9c892008-02-04 23:50:05 -0500203 vq->vring.desc[i].addr = sg_phys(sg);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000204 vq->vring.desc[i].len = sg->length;
205 prev = i;
206 sg++;
207 }
208 for (; in; i = vq->vring.desc[i].next, in--) {
209 vq->vring.desc[i].flags = VRING_DESC_F_NEXT|VRING_DESC_F_WRITE;
Rusty Russell15f9c892008-02-04 23:50:05 -0500210 vq->vring.desc[i].addr = sg_phys(sg);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000211 vq->vring.desc[i].len = sg->length;
212 prev = i;
213 sg++;
214 }
215 /* Last one doesn't continue. */
216 vq->vring.desc[prev].flags &= ~VRING_DESC_F_NEXT;
217
218 /* Update free pointer */
219 vq->free_head = i;
220
Mark McLoughlin9fa29b9d2009-05-11 18:11:45 +0100221add_head:
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000222 /* Set token. */
223 vq->data[head] = data;
224
225 /* Put entry in available array (but don't update avail->idx until they
226 * do sync). FIXME: avoid modulus here? */
227 avail = (vq->vring.avail->idx + vq->num_added++) % vq->vring.num;
228 vq->vring.avail->ring[avail] = head;
229
230 pr_debug("Added buffer head %i to %p\n", head, vq);
231 END_USE(vq);
Rusty Russell3c1b27d2009-09-23 22:26:31 -0600232
Rusty Russell3c1b27d2009-09-23 22:26:31 -0600233 return vq->num_free;
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000234}
Michael S. Tsirkinbbd603e2010-04-29 17:26:37 +0300235EXPORT_SYMBOL_GPL(virtqueue_add_buf_gfp);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000236
Michael S. Tsirkin7c5e9ed2010-04-12 16:19:07 +0300237void virtqueue_kick(struct virtqueue *_vq)
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000238{
239 struct vring_virtqueue *vq = to_vvq(_vq);
240 START_USE(vq);
241 /* Descriptors and available array need to be set before we expose the
242 * new available array entries. */
Michael S. Tsirkind57ed952010-01-28 00:42:23 +0200243 virtio_wmb();
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000244
245 vq->vring.avail->idx += vq->num_added;
246 vq->num_added = 0;
247
248 /* Need to update avail index before checking if we should notify */
Michael S. Tsirkind57ed952010-01-28 00:42:23 +0200249 virtio_mb();
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000250
251 if (!(vq->vring.used->flags & VRING_USED_F_NO_NOTIFY))
252 /* Prod other side to tell it about changes. */
253 vq->notify(&vq->vq);
254
255 END_USE(vq);
256}
Michael S. Tsirkin7c5e9ed2010-04-12 16:19:07 +0300257EXPORT_SYMBOL_GPL(virtqueue_kick);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000258
259static void detach_buf(struct vring_virtqueue *vq, unsigned int head)
260{
261 unsigned int i;
262
263 /* Clear data ptr. */
264 vq->data[head] = NULL;
265
266 /* Put back on free list: find end */
267 i = head;
Mark McLoughlin9fa29b9d2009-05-11 18:11:45 +0100268
269 /* Free the indirect table */
270 if (vq->vring.desc[i].flags & VRING_DESC_F_INDIRECT)
271 kfree(phys_to_virt(vq->vring.desc[i].addr));
272
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000273 while (vq->vring.desc[i].flags & VRING_DESC_F_NEXT) {
274 i = vq->vring.desc[i].next;
275 vq->num_free++;
276 }
277
278 vq->vring.desc[i].next = vq->free_head;
279 vq->free_head = head;
280 /* Plus final descriptor */
281 vq->num_free++;
282}
283
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000284static inline bool more_used(const struct vring_virtqueue *vq)
285{
286 return vq->last_used_idx != vq->vring.used->idx;
287}
288
Michael S. Tsirkin7c5e9ed2010-04-12 16:19:07 +0300289void *virtqueue_get_buf(struct virtqueue *_vq, unsigned int *len)
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000290{
291 struct vring_virtqueue *vq = to_vvq(_vq);
292 void *ret;
293 unsigned int i;
294
295 START_USE(vq);
296
Rusty Russell5ef82752008-05-02 21:50:43 -0500297 if (unlikely(vq->broken)) {
298 END_USE(vq);
299 return NULL;
300 }
301
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000302 if (!more_used(vq)) {
303 pr_debug("No more buffers in queue\n");
304 END_USE(vq);
305 return NULL;
306 }
307
Michael S. Tsirkin2d61ba92009-10-25 15:28:53 +0200308 /* Only get used array entries after they have been exposed by host. */
Michael S. Tsirkind57ed952010-01-28 00:42:23 +0200309 virtio_rmb();
Michael S. Tsirkin2d61ba92009-10-25 15:28:53 +0200310
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000311 i = vq->vring.used->ring[vq->last_used_idx%vq->vring.num].id;
312 *len = vq->vring.used->ring[vq->last_used_idx%vq->vring.num].len;
313
314 if (unlikely(i >= vq->vring.num)) {
315 BAD_RING(vq, "id %u out of range\n", i);
316 return NULL;
317 }
318 if (unlikely(!vq->data[i])) {
319 BAD_RING(vq, "id %u is not a head!\n", i);
320 return NULL;
321 }
322
323 /* detach_buf clears data, so grab it now. */
324 ret = vq->data[i];
325 detach_buf(vq, i);
326 vq->last_used_idx++;
327 END_USE(vq);
328 return ret;
329}
Michael S. Tsirkin7c5e9ed2010-04-12 16:19:07 +0300330EXPORT_SYMBOL_GPL(virtqueue_get_buf);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000331
Michael S. Tsirkin7c5e9ed2010-04-12 16:19:07 +0300332void virtqueue_disable_cb(struct virtqueue *_vq)
Rusty Russell18445c42008-02-04 23:49:57 -0500333{
334 struct vring_virtqueue *vq = to_vvq(_vq);
335
Rusty Russell18445c42008-02-04 23:49:57 -0500336 vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
Rusty Russell18445c42008-02-04 23:49:57 -0500337}
Michael S. Tsirkin7c5e9ed2010-04-12 16:19:07 +0300338EXPORT_SYMBOL_GPL(virtqueue_disable_cb);
Rusty Russell18445c42008-02-04 23:49:57 -0500339
Michael S. Tsirkin7c5e9ed2010-04-12 16:19:07 +0300340bool virtqueue_enable_cb(struct virtqueue *_vq)
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000341{
342 struct vring_virtqueue *vq = to_vvq(_vq);
343
344 START_USE(vq);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000345
346 /* We optimistically turn back on interrupts, then check if there was
347 * more to do. */
348 vq->vring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;
Michael S. Tsirkind57ed952010-01-28 00:42:23 +0200349 virtio_mb();
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000350 if (unlikely(more_used(vq))) {
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000351 END_USE(vq);
352 return false;
353 }
354
355 END_USE(vq);
356 return true;
357}
Michael S. Tsirkin7c5e9ed2010-04-12 16:19:07 +0300358EXPORT_SYMBOL_GPL(virtqueue_enable_cb);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000359
Michael S. Tsirkin7c5e9ed2010-04-12 16:19:07 +0300360void *virtqueue_detach_unused_buf(struct virtqueue *_vq)
Shirley Mac021eac2010-01-18 19:15:23 +0530361{
362 struct vring_virtqueue *vq = to_vvq(_vq);
363 unsigned int i;
364 void *buf;
365
366 START_USE(vq);
367
368 for (i = 0; i < vq->vring.num; i++) {
369 if (!vq->data[i])
370 continue;
371 /* detach_buf clears data, so grab it now. */
372 buf = vq->data[i];
373 detach_buf(vq, i);
374 END_USE(vq);
375 return buf;
376 }
377 /* That should have freed everything. */
378 BUG_ON(vq->num_free != vq->vring.num);
379
380 END_USE(vq);
381 return NULL;
382}
Michael S. Tsirkin7c5e9ed2010-04-12 16:19:07 +0300383EXPORT_SYMBOL_GPL(virtqueue_detach_unused_buf);
Shirley Mac021eac2010-01-18 19:15:23 +0530384
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000385irqreturn_t vring_interrupt(int irq, void *_vq)
386{
387 struct vring_virtqueue *vq = to_vvq(_vq);
388
389 if (!more_used(vq)) {
390 pr_debug("virtqueue interrupt with no work for %p\n", vq);
391 return IRQ_NONE;
392 }
393
394 if (unlikely(vq->broken))
395 return IRQ_HANDLED;
396
397 pr_debug("virtqueue callback for %p (%p)\n", vq, vq->vq.callback);
Rusty Russell18445c42008-02-04 23:49:57 -0500398 if (vq->vq.callback)
399 vq->vq.callback(&vq->vq);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000400
401 return IRQ_HANDLED;
402}
Rusty Russellc6fd4702008-02-04 23:50:05 -0500403EXPORT_SYMBOL_GPL(vring_interrupt);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000404
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000405struct virtqueue *vring_new_virtqueue(unsigned int num,
Rusty Russell87c7d572008-12-30 09:26:03 -0600406 unsigned int vring_align,
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000407 struct virtio_device *vdev,
408 void *pages,
409 void (*notify)(struct virtqueue *),
Rusty Russell9499f5e2009-06-12 22:16:35 -0600410 void (*callback)(struct virtqueue *),
411 const char *name)
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000412{
413 struct vring_virtqueue *vq;
414 unsigned int i;
415
Rusty Russell42b36cc2007-11-12 13:39:18 +1100416 /* We assume num is a power of 2. */
417 if (num & (num - 1)) {
418 dev_warn(&vdev->dev, "Bad virtqueue length %u\n", num);
419 return NULL;
420 }
421
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000422 vq = kmalloc(sizeof(*vq) + sizeof(void *)*num, GFP_KERNEL);
423 if (!vq)
424 return NULL;
425
Rusty Russell87c7d572008-12-30 09:26:03 -0600426 vring_init(&vq->vring, num, pages, vring_align);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000427 vq->vq.callback = callback;
428 vq->vq.vdev = vdev;
Rusty Russell9499f5e2009-06-12 22:16:35 -0600429 vq->vq.name = name;
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000430 vq->notify = notify;
431 vq->broken = false;
432 vq->last_used_idx = 0;
433 vq->num_added = 0;
Rusty Russell9499f5e2009-06-12 22:16:35 -0600434 list_add_tail(&vq->vq.list, &vdev->vqs);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000435#ifdef DEBUG
436 vq->in_use = false;
437#endif
438
Mark McLoughlin9fa29b9d2009-05-11 18:11:45 +0100439 vq->indirect = virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC);
440
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000441 /* No callback? Tell other side not to bother us. */
442 if (!callback)
443 vq->vring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
444
445 /* Put everything in free lists. */
446 vq->num_free = num;
447 vq->free_head = 0;
Amit Shah3b870622010-02-12 10:32:14 +0530448 for (i = 0; i < num-1; i++) {
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000449 vq->vring.desc[i].next = i+1;
Amit Shah3b870622010-02-12 10:32:14 +0530450 vq->data[i] = NULL;
451 }
452 vq->data[i] = NULL;
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000453
454 return &vq->vq;
455}
Rusty Russellc6fd4702008-02-04 23:50:05 -0500456EXPORT_SYMBOL_GPL(vring_new_virtqueue);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000457
458void vring_del_virtqueue(struct virtqueue *vq)
459{
Rusty Russell9499f5e2009-06-12 22:16:35 -0600460 list_del(&vq->list);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000461 kfree(to_vvq(vq));
462}
Rusty Russellc6fd4702008-02-04 23:50:05 -0500463EXPORT_SYMBOL_GPL(vring_del_virtqueue);
Rusty Russell0a8a69d2007-10-22 11:03:40 +1000464
Rusty Russelle34f8722008-07-25 12:06:13 -0500465/* Manipulates transport-specific feature bits. */
466void vring_transport_features(struct virtio_device *vdev)
467{
468 unsigned int i;
469
470 for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) {
471 switch (i) {
Mark McLoughlin9fa29b9d2009-05-11 18:11:45 +0100472 case VIRTIO_RING_F_INDIRECT_DESC:
473 break;
Rusty Russelle34f8722008-07-25 12:06:13 -0500474 default:
475 /* We don't understand this bit. */
476 clear_bit(i, vdev->features);
477 }
478 }
479}
480EXPORT_SYMBOL_GPL(vring_transport_features);
481
Rusty Russellc6fd4702008-02-04 23:50:05 -0500482MODULE_LICENSE("GPL");