vsock.c (2a267e7c41aa88215de2b542de797d03d16ecdfd) | vsock.c (e82b9b0727ff6d665fff2d326162b460dded554d) |
---|---|
1/* 2 * vhost transport for vsock 3 * 4 * Copyright (C) 2013-2015 Red Hat, Inc. 5 * Author: Asias He <asias@redhat.com> 6 * Stefan Hajnoczi <stefanha@redhat.com> 7 * 8 * This work is licensed under the terms of the GNU GPL, version 2. --- 7 unchanged lines hidden (view full) --- 16#include <linux/virtio_vsock.h> 17#include <linux/vhost.h> 18#include <linux/hashtable.h> 19 20#include <net/af_vsock.h> 21#include "vhost.h" 22 23#define VHOST_VSOCK_DEFAULT_HOST_CID 2 | 1/* 2 * vhost transport for vsock 3 * 4 * Copyright (C) 2013-2015 Red Hat, Inc. 5 * Author: Asias He <asias@redhat.com> 6 * Stefan Hajnoczi <stefanha@redhat.com> 7 * 8 * This work is licensed under the terms of the GNU GPL, version 2. --- 7 unchanged lines hidden (view full) --- 16#include <linux/virtio_vsock.h> 17#include <linux/vhost.h> 18#include <linux/hashtable.h> 19 20#include <net/af_vsock.h> 21#include "vhost.h" 22 23#define VHOST_VSOCK_DEFAULT_HOST_CID 2 |
24/* Max number of bytes transferred before requeueing the job. 25 * Using this limit prevents one virtqueue from starving others. */ 26#define VHOST_VSOCK_WEIGHT 0x80000 27/* Max number of packets transferred before requeueing the job. 28 * Using this limit prevents one virtqueue from starving others with 29 * small pkts. 30 */ 31#define VHOST_VSOCK_PKT_WEIGHT 256 |
|
24 25enum { 26 VHOST_VSOCK_FEATURES = VHOST_FEATURES, 27}; 28 29/* Used to track all the vhost_vsock instances on the system. */ 30static DEFINE_MUTEX(vhost_vsock_mutex); 31static DEFINE_READ_MOSTLY_HASHTABLE(vhost_vsock_hash, 8); --- 494 unchanged lines hidden (view full) --- 526 527 atomic_set(&vsock->queued_replies, 0); 528 529 vqs[VSOCK_VQ_TX] = &vsock->vqs[VSOCK_VQ_TX]; 530 vqs[VSOCK_VQ_RX] = &vsock->vqs[VSOCK_VQ_RX]; 531 vsock->vqs[VSOCK_VQ_TX].handle_kick = vhost_vsock_handle_tx_kick; 532 vsock->vqs[VSOCK_VQ_RX].handle_kick = vhost_vsock_handle_rx_kick; 533 | 32 33enum { 34 VHOST_VSOCK_FEATURES = VHOST_FEATURES, 35}; 36 37/* Used to track all the vhost_vsock instances on the system. */ 38static DEFINE_MUTEX(vhost_vsock_mutex); 39static DEFINE_READ_MOSTLY_HASHTABLE(vhost_vsock_hash, 8); --- 494 unchanged lines hidden (view full) --- 534 535 atomic_set(&vsock->queued_replies, 0); 536 537 vqs[VSOCK_VQ_TX] = &vsock->vqs[VSOCK_VQ_TX]; 538 vqs[VSOCK_VQ_RX] = &vsock->vqs[VSOCK_VQ_RX]; 539 vsock->vqs[VSOCK_VQ_TX].handle_kick = vhost_vsock_handle_tx_kick; 540 vsock->vqs[VSOCK_VQ_RX].handle_kick = vhost_vsock_handle_rx_kick; 541 |
534 vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs), UIO_MAXIOV); | 542 vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs), 543 UIO_MAXIOV, VHOST_VSOCK_PKT_WEIGHT, 544 VHOST_VSOCK_WEIGHT); |
535 536 file->private_data = vsock; 537 spin_lock_init(&vsock->send_pkt_list_lock); 538 INIT_LIST_HEAD(&vsock->send_pkt_list); 539 vhost_work_init(&vsock->send_pkt_work, vhost_transport_send_pkt_work); 540 return 0; 541 542out: --- 270 unchanged lines hidden --- | 545 546 file->private_data = vsock; 547 spin_lock_init(&vsock->send_pkt_list_lock); 548 INIT_LIST_HEAD(&vsock->send_pkt_list); 549 vhost_work_init(&vsock->send_pkt_work, vhost_transport_send_pkt_work); 550 return 0; 551 552out: --- 270 unchanged lines hidden --- |