virtio_ring.c (4ba24fef3eb3b142197135223b90ced2f319cd53) | virtio_ring.c (5e05bf5833eb3dd97b6b6a52301d81e033714cb3) |
---|---|
1/* 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. --- 40 unchanged lines hidden (view full) --- 49 dev_err(&_vq->vq.vdev->dev, \ 50 "%s:"fmt, (_vq)->vq.name, ##args); \ 51 (_vq)->broken = true; \ 52 } while (0) 53#define START_USE(vq) 54#define END_USE(vq) 55#endif 56 | 1/* 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. --- 40 unchanged lines hidden (view full) --- 49 dev_err(&_vq->vq.vdev->dev, \ 50 "%s:"fmt, (_vq)->vq.name, ##args); \ 51 (_vq)->broken = true; \ 52 } while (0) 53#define START_USE(vq) 54#define END_USE(vq) 55#endif 56 |
57struct vring_virtqueue 58{ | 57struct vring_virtqueue { |
59 struct virtqueue vq; 60 61 /* Actual memory layout for this queue */ 62 struct vring vring; 63 64 /* Can we use weak barriers? */ 65 bool weak_barriers; 66 --- 173 unchanged lines hidden (view full) --- 240 vq->vring.avail->ring[avail] = cpu_to_virtio16(_vq->vdev, head); 241 242 /* Descriptors and available array need to be set before we expose the 243 * new available array entries. */ 244 virtio_wmb(vq->weak_barriers); 245 vq->vring.avail->idx = cpu_to_virtio16(_vq->vdev, virtio16_to_cpu(_vq->vdev, vq->vring.avail->idx) + 1); 246 vq->num_added++; 247 | 58 struct virtqueue vq; 59 60 /* Actual memory layout for this queue */ 61 struct vring vring; 62 63 /* Can we use weak barriers? */ 64 bool weak_barriers; 65 --- 173 unchanged lines hidden (view full) --- 239 vq->vring.avail->ring[avail] = cpu_to_virtio16(_vq->vdev, head); 240 241 /* Descriptors and available array need to be set before we expose the 242 * new available array entries. */ 243 virtio_wmb(vq->weak_barriers); 244 vq->vring.avail->idx = cpu_to_virtio16(_vq->vdev, virtio16_to_cpu(_vq->vdev, vq->vring.avail->idx) + 1); 245 vq->num_added++; 246 |
247 pr_debug("Added buffer head %i to %p\n", head, vq); 248 END_USE(vq); 249 |
|
248 /* This is very unlikely, but theoretically possible. Kick 249 * just in case. */ 250 if (unlikely(vq->num_added == (1 << 16) - 1)) 251 virtqueue_kick(_vq); 252 | 250 /* This is very unlikely, but theoretically possible. Kick 251 * just in case. */ 252 if (unlikely(vq->num_added == (1 << 16) - 1)) 253 virtqueue_kick(_vq); 254 |
253 pr_debug("Added buffer head %i to %p\n", head, vq); 254 END_USE(vq); 255 | |
256 return 0; 257} 258 259/** 260 * virtqueue_add_sgs - expose buffers to other end 261 * @vq: the struct virtqueue we're talking about. 262 * @sgs: array of terminated scatterlists. 263 * @out_num: the number of scatterlists readable by other side --- 585 unchanged lines hidden --- | 255 return 0; 256} 257 258/** 259 * virtqueue_add_sgs - expose buffers to other end 260 * @vq: the struct virtqueue we're talking about. 261 * @sgs: array of terminated scatterlists. 262 * @out_num: the number of scatterlists readable by other side --- 585 unchanged lines hidden --- |