From: "Michael S. Tsirkin" <mst@redhat.com>
To: Amos Kong <akong@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>,
rusty@rustcorp.com.au, qemu-devel@nongnu.org,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: Re: [Qemu-devel] [RFC PATCH 2/2] virtio-net: introduce a new control to set macaddr
Date: Wed, 16 Jan 2013 11:17:09 +0200 [thread overview]
Message-ID: <20130116091709.GB12723@redhat.com> (raw)
In-Reply-To: <20130116052326.GA4279@t430s.nay.redhat.com>
On Wed, Jan 16, 2013 at 01:23:26PM +0800, Amos Kong wrote:
> On Thu, Jan 10, 2013 at 10:57:05PM +0800, Jason Wang wrote:
> > On 01/10/2013 10:45 PM, akong@redhat.com wrote:
> > > From: Amos Kong <akong@redhat.com>
> > >
> > > Currently we write MAC address to pci config space byte by byte,
> > > this means that we have an intermediate step where mac is wrong.
> > > This patch introduced a new control command to set MAC address
> > > in one time.
> > >
> > > VIRTIO_NET_F_CTRL_MAC_ADDR is a new feature bit for compatibility.
> > >
> > > Signed-off-by: Amos Kong <akong@redhat.com>
> > > ---
> > > drivers/net/virtio_net.c | 16 +++++++++++++++-
> > > include/uapi/linux/virtio_net.h | 8 +++++++-
> > > 2 files changed, 22 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > > index 395ab4f..ff22bcd 100644
> > > --- a/drivers/net/virtio_net.c
> > > +++ b/drivers/net/virtio_net.c
> > > @@ -803,13 +803,26 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
> > > struct virtio_device *vdev = vi->vdev;
> > > int ret;
> > >
> > > + struct scatterlist sg;
> > > +
> > > ret = eth_mac_addr(dev, p);
> > > if (ret)
> > > return ret;
> > >
> > > - if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC))
> > > + if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR)) {
> > > + /* Set MAC address by sending vq command */
> > > + sg_init_one(&sg, dev->dev_addr, dev->addr_len);
> > > + virtnet_send_command(vi, VIRTIO_NET_CTRL_MAC,
> > > + VIRTIO_NET_CTRL_MAC_ADDR_SET,
> > > + &sg, 1, 0);
> > > + return 0;
> > > + }
> > > +
> >
> > Better to check the return of virtnet_send_command() and give a warn
> > like other command. Btw, need we fail back to try the old way then?
>
> Yes, it's necessary to check the return value of
> virtnet_send_command().
>
> In fail case, I like to return -EINVAL to userspace, because we don't
> only want to set mac successfully, we also want to resolve the
> addr inconsistent issue by this feature (vq cmd).
It's really a device error but I guess we can.
We probably should print a warning too.
--
MST
next prev parent reply other threads:[~2013-01-16 12:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-10 14:45 [Qemu-devel] [RFC PATCH 0/2] make mac programming for virtio net more robust akong
2013-01-10 14:45 ` [Qemu-devel] [RFC PATCH 1/2] move virtnet_send_command() above virtnet_set_mac_address() akong
2013-01-10 14:51 ` Jason Wang
2013-01-10 15:02 ` Michael S. Tsirkin
2013-01-10 14:45 ` [Qemu-devel] [RFC PATCH 2/2] virtio-net: introduce a new control to set macaddr akong
2013-01-10 14:57 ` Jason Wang
2013-01-16 5:23 ` Amos Kong
2013-01-16 9:17 ` Michael S. Tsirkin [this message]
2013-01-10 15:26 ` Michael S. Tsirkin
2013-01-11 0:43 ` Rusty Russell
2013-01-10 14:51 ` [Qemu-devel] [RFC PATCH] virtio-net: introduce a new macaddr control akong
2013-01-11 9:50 ` Stefan Hajnoczi
2013-01-10 15:08 ` [Qemu-devel] [RFC PATCH 0/2] make mac programming for virtio net more robust Amos Kong
2013-01-10 15:28 ` Michael S. Tsirkin
2013-01-11 2:23 ` Rusty Russell
2013-01-11 7:46 ` Michael S. Tsirkin
2013-01-11 14:52 ` John Fastabend
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=20130116091709.GB12723@redhat.com \
--to=mst@redhat.com \
--cc=akong@redhat.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=rusty@rustcorp.com.au \
--cc=virtualization@lists.linux-foundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).