diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2008-08-26 01:19:27 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2008-08-25 10:19:28 -0400 |
commit | 1dc3e3bcbfe335843ec938bfdddb34d10f4dd278 (patch) | |
tree | 8666189f7a285c8e4c6512784dff39971fefa30c | |
parent | bf2002967775cbb233876d51ff94e8daa7e77858 (diff) |
lguest: update commentry
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r-- | Documentation/lguest/lguest.c | 8 | ||||
-rw-r--r-- | drivers/lguest/lguest_device.c | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c index 655414821edc..7228369d1014 100644 --- a/Documentation/lguest/lguest.c +++ b/Documentation/lguest/lguest.c | |||
@@ -895,6 +895,9 @@ static void handle_console_output(int fd, struct virtqueue *vq, bool timeout) | |||
895 | } | 895 | } |
896 | } | 896 | } |
897 | 897 | ||
898 | /* This is called when we no longer want to hear about Guest changes to a | ||
899 | * virtqueue. This is more efficient in high-traffic cases, but it means we | ||
900 | * have to set a timer to check if any more changes have occurred. */ | ||
898 | static void block_vq(struct virtqueue *vq) | 901 | static void block_vq(struct virtqueue *vq) |
899 | { | 902 | { |
900 | struct itimerval itm; | 903 | struct itimerval itm; |
@@ -939,6 +942,11 @@ static void handle_net_output(int fd, struct virtqueue *vq, bool timeout) | |||
939 | if (!timeout && num) | 942 | if (!timeout && num) |
940 | block_vq(vq); | 943 | block_vq(vq); |
941 | 944 | ||
945 | /* We never quite know how long should we wait before we check the | ||
946 | * queue again for more packets. We start at 500 microseconds, and if | ||
947 | * we get fewer packets than last time, we assume we made the timeout | ||
948 | * too small and increase it by 10 microseconds. Otherwise, we drop it | ||
949 | * by one microsecond every time. It seems to work well enough. */ | ||
942 | if (timeout) { | 950 | if (timeout) { |
943 | if (num < last_timeout_num) | 951 | if (num < last_timeout_num) |
944 | timeout_usec += 10; | 952 | timeout_usec += 10; |
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c index 37344aaee22f..a661bbdae3d6 100644 --- a/drivers/lguest/lguest_device.c +++ b/drivers/lguest/lguest_device.c | |||
@@ -98,6 +98,10 @@ static u32 lg_get_features(struct virtio_device *vdev) | |||
98 | return features; | 98 | return features; |
99 | } | 99 | } |
100 | 100 | ||
101 | /* The virtio core takes the features the Host offers, and copies the | ||
102 | * ones supported by the driver into the vdev->features array. Once | ||
103 | * that's all sorted out, this routine is called so we can tell the | ||
104 | * Host which features we understand and accept. */ | ||
101 | static void lg_finalize_features(struct virtio_device *vdev) | 105 | static void lg_finalize_features(struct virtio_device *vdev) |
102 | { | 106 | { |
103 | unsigned int i, bits; | 107 | unsigned int i, bits; |
@@ -108,6 +112,10 @@ static void lg_finalize_features(struct virtio_device *vdev) | |||
108 | /* Give virtio_ring a chance to accept features. */ | 112 | /* Give virtio_ring a chance to accept features. */ |
109 | vring_transport_features(vdev); | 113 | vring_transport_features(vdev); |
110 | 114 | ||
115 | /* The vdev->feature array is a Linux bitmask: this isn't the | ||
116 | * same as a the simple array of bits used by lguest devices | ||
117 | * for features. So we do this slow, manual conversion which is | ||
118 | * completely general. */ | ||
111 | memset(out_features, 0, desc->feature_len); | 119 | memset(out_features, 0, desc->feature_len); |
112 | bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8; | 120 | bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8; |
113 | for (i = 0; i < bits; i++) { | 121 | for (i = 0; i < bits; i++) { |