diff options
author | Jason Wang <jasowang@redhat.com> | 2011-01-17 03:10:59 -0500 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2011-03-13 10:57:30 -0400 |
commit | cfbdab951369f15de890597530076bf0119361be (patch) | |
tree | f6abfd1324d7d57784545f9dda4e4fbf60570053 /drivers/vhost/net.c | |
parent | fcc042a2806064ffcaed7a0c5cb710eca0e99108 (diff) |
vhost-net: check the support of mergeable buffer outside the receive loop
No need to check the support of mergeable buffer inside the recevie
loop as the whole handle_rx()_xx is in the read critical region. So
this patch move it ahead of the receiving loop.
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/vhost/net.c')
-rw-r--r-- | drivers/vhost/net.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 59dad9fe52dd..9f57cd45fe8f 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c | |||
@@ -411,7 +411,7 @@ static void handle_rx_mergeable(struct vhost_net *net) | |||
411 | .hdr.gso_type = VIRTIO_NET_HDR_GSO_NONE | 411 | .hdr.gso_type = VIRTIO_NET_HDR_GSO_NONE |
412 | }; | 412 | }; |
413 | size_t total_len = 0; | 413 | size_t total_len = 0; |
414 | int err, headcount; | 414 | int err, headcount, mergeable; |
415 | size_t vhost_hlen, sock_hlen; | 415 | size_t vhost_hlen, sock_hlen; |
416 | size_t vhost_len, sock_len; | 416 | size_t vhost_len, sock_len; |
417 | /* TODO: check that we are running from vhost_worker? */ | 417 | /* TODO: check that we are running from vhost_worker? */ |
@@ -427,6 +427,7 @@ static void handle_rx_mergeable(struct vhost_net *net) | |||
427 | 427 | ||
428 | vq_log = unlikely(vhost_has_feature(&net->dev, VHOST_F_LOG_ALL)) ? | 428 | vq_log = unlikely(vhost_has_feature(&net->dev, VHOST_F_LOG_ALL)) ? |
429 | vq->log : NULL; | 429 | vq->log : NULL; |
430 | mergeable = vhost_has_feature(&net->dev, VIRTIO_NET_F_MRG_RXBUF); | ||
430 | 431 | ||
431 | while ((sock_len = peek_head_len(sock->sk))) { | 432 | while ((sock_len = peek_head_len(sock->sk))) { |
432 | sock_len += sock_hlen; | 433 | sock_len += sock_hlen; |
@@ -476,7 +477,7 @@ static void handle_rx_mergeable(struct vhost_net *net) | |||
476 | break; | 477 | break; |
477 | } | 478 | } |
478 | /* TODO: Should check and handle checksum. */ | 479 | /* TODO: Should check and handle checksum. */ |
479 | if (vhost_has_feature(&net->dev, VIRTIO_NET_F_MRG_RXBUF) && | 480 | if (likely(mergeable) && |
480 | memcpy_toiovecend(vq->hdr, (unsigned char *)&headcount, | 481 | memcpy_toiovecend(vq->hdr, (unsigned char *)&headcount, |
481 | offsetof(typeof(hdr), num_buffers), | 482 | offsetof(typeof(hdr), num_buffers), |
482 | sizeof hdr.num_buffers)) { | 483 | sizeof hdr.num_buffers)) { |