aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2012-11-01 05:16:42 -0400
committerDavid S. Miller <davem@davemloft.net>2012-11-02 21:29:57 -0400
commitc4fcb586c337f8b8de3a3d7ba8514eed03695f6e (patch)
treeba018d4de83d2e4a9898e06e9f813359a56d85fd /drivers/vhost
parent70e4cb9aafb3caa9e5eb25614a5bc40b0ffa9ffd (diff)
vhost: track zero copy failures using DMA length
This will be used to disable zerocopy when error rate is high. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/vhost.c7
-rw-r--r--drivers/vhost/vhost.h4
2 files changed, 8 insertions, 3 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index f23cf8956d19..5affce325031 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -425,7 +425,7 @@ int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq)
425 int j = 0; 425 int j = 0;
426 426
427 for (i = vq->done_idx; i != vq->upend_idx; i = (i + 1) % UIO_MAXIOV) { 427 for (i = vq->done_idx; i != vq->upend_idx; i = (i + 1) % UIO_MAXIOV) {
428 if ((vq->heads[i].len == VHOST_DMA_DONE_LEN)) { 428 if (VHOST_DMA_IS_DONE(vq->heads[i].len)) {
429 vq->heads[i].len = VHOST_DMA_CLEAR_LEN; 429 vq->heads[i].len = VHOST_DMA_CLEAR_LEN;
430 vhost_add_used_and_signal(vq->dev, vq, 430 vhost_add_used_and_signal(vq->dev, vq,
431 vq->heads[i].id, 0); 431 vq->heads[i].id, 0);
@@ -1600,13 +1600,14 @@ void vhost_ubuf_put_and_wait(struct vhost_ubuf_ref *ubufs)
1600 kfree(ubufs); 1600 kfree(ubufs);
1601} 1601}
1602 1602
1603void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool status) 1603void vhost_zerocopy_callback(struct ubuf_info *ubuf, int status)
1604{ 1604{
1605 struct vhost_ubuf_ref *ubufs = ubuf->ctx; 1605 struct vhost_ubuf_ref *ubufs = ubuf->ctx;
1606 struct vhost_virtqueue *vq = ubufs->vq; 1606 struct vhost_virtqueue *vq = ubufs->vq;
1607 1607
1608 vhost_poll_queue(&vq->poll); 1608 vhost_poll_queue(&vq->poll);
1609 /* set len to mark this desc buffers done DMA */ 1609 /* set len to mark this desc buffers done DMA */
1610 vq->heads[ubuf->desc].len = VHOST_DMA_DONE_LEN; 1610 vq->heads[ubuf->desc].len = status ?
1611 VHOST_DMA_FAILED_LEN : VHOST_DMA_DONE_LEN;
1611 kref_put(&ubufs->kref, vhost_zerocopy_done_signal); 1612 kref_put(&ubufs->kref, vhost_zerocopy_done_signal);
1612} 1613}
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index b6538eef7468..464469d901d5 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -17,6 +17,8 @@
17 * For transmit, used buffer len is unused; we override it to track buffer 17 * For transmit, used buffer len is unused; we override it to track buffer
18 * status internally; used for zerocopy tx only. 18 * status internally; used for zerocopy tx only.
19 */ 19 */
20/* Lower device DMA failed */
21#define VHOST_DMA_FAILED_LEN 3
20/* Lower device DMA done */ 22/* Lower device DMA done */
21#define VHOST_DMA_DONE_LEN 2 23#define VHOST_DMA_DONE_LEN 2
22/* Lower device DMA in progress */ 24/* Lower device DMA in progress */
@@ -24,6 +26,8 @@
24/* Buffer unused */ 26/* Buffer unused */
25#define VHOST_DMA_CLEAR_LEN 0 27#define VHOST_DMA_CLEAR_LEN 0
26 28
29#define VHOST_DMA_IS_DONE(len) ((len) >= VHOST_DMA_DONE_LEN)
30
27struct vhost_device; 31struct vhost_device;
28 32
29struct vhost_work; 33struct vhost_work;