提交 b0d0ea50 编写于 作者: J Jason Wang 提交者: David S. Miller

vhost_net: introduce helper to initialize tx iov iter

Introduce init_iov_iter() in order to be reused by future patch.
Signed-off-by: NJason Wang <jasowang@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 652e4f3e
...@@ -466,6 +466,18 @@ static bool vhost_exceeds_maxpend(struct vhost_net *net) ...@@ -466,6 +466,18 @@ static bool vhost_exceeds_maxpend(struct vhost_net *net)
min_t(unsigned int, VHOST_MAX_PEND, vq->num >> 2); min_t(unsigned int, VHOST_MAX_PEND, vq->num >> 2);
} }
static size_t init_iov_iter(struct vhost_virtqueue *vq, struct iov_iter *iter,
size_t hdr_size, int out)
{
/* Skip header. TODO: support TSO. */
size_t len = iov_length(vq->iov, out);
iov_iter_init(iter, WRITE, vq->iov, out, len);
iov_iter_advance(iter, hdr_size);
return iov_iter_count(iter);
}
/* Expects to be always run from workqueue - which acts as /* Expects to be always run from workqueue - which acts as
* read-size critical section for our kind of RCU. */ * read-size critical section for our kind of RCU. */
static void handle_tx(struct vhost_net *net) static void handle_tx(struct vhost_net *net)
...@@ -531,18 +543,14 @@ static void handle_tx(struct vhost_net *net) ...@@ -531,18 +543,14 @@ static void handle_tx(struct vhost_net *net)
"out %d, int %d\n", out, in); "out %d, int %d\n", out, in);
break; break;
} }
/* Skip header. TODO: support TSO. */
len = iov_length(vq->iov, out);
iov_iter_init(&msg.msg_iter, WRITE, vq->iov, out, len);
iov_iter_advance(&msg.msg_iter, hdr_size);
/* Sanity check */ /* Sanity check */
if (!msg_data_left(&msg)) { len = init_iov_iter(vq, &msg.msg_iter, hdr_size, out);
vq_err(vq, "Unexpected header len for TX: " if (!len) {
"%zd expected %zd\n", vq_err(vq, "Unexpected header len for TX: %zd expected %zd\n",
len, hdr_size); len, hdr_size);
break; break;
} }
len = msg_data_left(&msg);
zcopy_used = zcopy && len >= VHOST_GOODCOPY_LEN zcopy_used = zcopy && len >= VHOST_GOODCOPY_LEN
&& !vhost_exceeds_maxpend(net) && !vhost_exceeds_maxpend(net)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册