From: "Michael S. Tsirkin" <mst@redhat.com>
To: xiaohui.xin@intel.com
Cc: netdev@vger.kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, mingo@elte.hu,
jdike@linux.intel.com
Subject: Re: [PATCH 1/3] A device for zero-copy based on KVM virtio-net.
Date: Wed, 7 Apr 2010 14:17:22 +0300 [thread overview]
Message-ID: <20100407111722.GA10711@redhat.com> (raw)
In-Reply-To: <1270630839-19876-1-git-send-email-xiaohui.xin@intel.com>
On Wed, Apr 07, 2010 at 05:00:39PM +0800, xiaohui.xin@intel.com wrote:
> From: Xin Xiaohui <xiaohui.xin@intel.com>
>
> ---
>
> Michael,
> Thanks a lot for the explanation. I have drafted a patch for the qemu write
> after I looked into tun driver. Does it do in right way?
>
> Thanks
> Xiaohui
>
> drivers/vhost/mpassthru.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 45 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/vhost/mpassthru.c b/drivers/vhost/mpassthru.c
> index e9449ac..1cde097 100644
> --- a/drivers/vhost/mpassthru.c
> +++ b/drivers/vhost/mpassthru.c
> @@ -1065,6 +1065,49 @@ static unsigned int mp_chr_poll(struct file *file, poll_table * wait)
> return mask;
> }
>
> +static ssize_t mp_chr_aio_write(struct kiocb *iocb, const struct iovec *iov,
> + unsigned long count, loff_t pos)
> +{
> + struct file *file = iocb->ki_filp;
> + struct mp_struct *mp = mp_get(file->private_data);
> + struct sock *sk = mp->socket.sk;
> + struct sk_buff *skb;
> + int len, err;
> + ssize_t result;
> +
> + if (!mp)
> + return -EBADFD;
> +
Can this happen? When?
> + /* currently, async is not supported */
> + if (!is_sync_kiocb(iocb))
> + return -EFAULT;
Really necessary? I think do_sync_write handles all this.
> +
> + len = iov_length(iov, count);
> + skb = sock_alloc_send_skb(sk, len + NET_IP_ALIGN,
> + file->f_flags & O_NONBLOCK, &err);
> +
> + if (!skb)
> + return -EFAULT;
Surely not EFAULT. -EAGAIN?
> +
> + skb_reserve(skb, NET_IP_ALIGN);
> + skb_put(skb, len);
> +
> + if (skb_copy_datagram_from_iovec(skb, 0, iov, 0, len)) {
> + kfree_skb(skb);
> + return -EFAULT;
> + }
> + skb_set_network_header(skb, ETH_HLEN);
Is this really right or necessary? Also,
probably need to check that length is at least ETH_ALEN before
doing this.
> + skb->protocol = *((__be16 *)(skb->data) + ETH_ALEN);
eth_type_trans?
> + skb->dev = mp->dev;
> +
> + dev_queue_xmit(skb);
> + mp->dev->stats.tx_packets++;
> + mp->dev->stats.tx_bytes += len;
Doesn't the hard start xmit function for the device
increment the counters?
> +
> + mp_put(mp);
> + return result;
> +}
> +
> static int mp_chr_close(struct inode *inode, struct file *file)
> {
> struct mp_file *mfile = file->private_data;
> @@ -1084,6 +1127,8 @@ static int mp_chr_close(struct inode *inode, struct file *file)
> static const struct file_operations mp_fops = {
> .owner = THIS_MODULE,
> .llseek = no_llseek,
> + .write = do_sync_write,
> + .aio_write = mp_chr_aio_write,
> .poll = mp_chr_poll,
> .unlocked_ioctl = mp_chr_ioctl,
> .open = mp_chr_open,
> --
> 1.5.4.4
next prev parent reply other threads:[~2010-04-07 11:21 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-06 9:38 [PATCH v1 0/3] Provide a zero-copy method on KVM virtio-net xiaohui.xin
2010-03-06 9:38 ` [PATCH v1 1/3] A device for zero-copy based " xiaohui.xin
2010-03-06 9:38 ` [PATCH v1 2/3] Provides multiple submits and asynchronous notifications xiaohui.xin
2010-03-06 9:38 ` [PATCH v1 3/3] Let host NIC driver to DMA to guest user space xiaohui.xin
2010-03-06 17:18 ` Stephen Hemminger
2010-03-08 11:18 ` Michael S. Tsirkin
2010-03-07 11:18 ` [PATCH v1 2/3] Provides multiple submits and asynchronous notifications Michael S. Tsirkin
2010-03-15 8:46 ` Xin, Xiaohui
2010-03-15 9:23 ` Michael S. Tsirkin
2010-03-16 9:32 ` Xin Xiaohui
2010-03-16 11:33 ` [PATCH " Michael S. Tsirkin
2010-03-17 9:48 ` Xin, Xiaohui
2010-03-17 10:27 ` Michael S. Tsirkin
2010-04-01 9:14 ` Xin Xiaohui
2010-04-01 11:02 ` [PATCH " Michael S. Tsirkin
2010-04-02 2:16 ` Xin, Xiaohui
2010-04-04 11:40 ` Michael S. Tsirkin
2010-04-06 5:46 ` Xin, Xiaohui
2010-04-06 7:51 ` Michael S. Tsirkin
2010-04-07 1:36 ` Xin, Xiaohui
2010-04-07 8:18 ` Michael S. Tsirkin
2010-04-08 9:07 ` xiaohui.xin
2010-03-08 11:28 ` [PATCH v1 1/3] A device for zero-copy based on KVM virtio-net Michael S. Tsirkin
2010-04-01 9:27 ` Xin Xiaohui
2010-04-01 11:08 ` [PATCH " Michael S. Tsirkin
2010-04-06 5:41 ` Xin, Xiaohui
2010-04-06 7:49 ` Michael S. Tsirkin
2010-04-07 2:41 ` Xin, Xiaohui
2010-04-07 8:15 ` Michael S. Tsirkin
2010-04-07 9:00 ` xiaohui.xin
2010-04-07 11:17 ` Michael S. Tsirkin [this message]
2010-03-07 10:50 ` [PATCH v1 0/3] Provide a zero-copy method " Michael S. Tsirkin
2010-03-09 7:47 ` Xin, Xiaohui
-- strict thread matches above, loose matches on Subject: below --
2010-02-10 11:48 [PATCH " Xin Xiaohui
2010-02-10 11:48 ` [PATCH 1/3] A device for zero-copy based " Xin Xiaohui
2010-02-10 15:17 ` Eric Dumazet
2010-02-11 5:33 ` Xin, Xiaohui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100407111722.GA10711@redhat.com \
--to=mst@redhat.com \
--cc=jdike@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=netdev@vger.kernel.org \
--cc=xiaohui.xin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.