From: Jason Wang <jasowang@redhat.com>
To: Cindy Lu <lulu@redhat.com>, mst@redhat.com, qemu-devel@nongnu.org
Cc: qemu-stable@nongnu.org
Subject: Re: [PATCH 1/3] virtio-net: Set mac address to hardware if the peer is vdpa
Date: Tue, 22 Sep 2020 09:54:53 +0800 [thread overview]
Message-ID: <b5ac3a30-6d81-117c-37af-e16b9a21ddad@redhat.com> (raw)
In-Reply-To: <20200917155851.20636-1-lulu@redhat.com>
On 2020/9/17 下午11:58, Cindy Lu wrote:
> If the peer's type is vdpa,set the mac address to NIC in virtio_net_device_realize,
> Also sometime vdpa get an all 0 macaddress from the hardware, this will cause the traffic down
> So we add the check for this part.
> if we get an 0 mac address we will use the default mac address instead
>
> Signed-off-by: Cindy Lu <lulu@redhat.com>
> ---
> hw/net/virtio-net.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index cb0d27084c..7db9da1482 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -126,6 +126,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
> VirtIONet *n = VIRTIO_NET(vdev);
> struct virtio_net_config netcfg;
> NetClientState *nc = qemu_get_queue(n->nic);
> + static const MACAddr zero = { .a = { 0, 0, 0, 0, 0, 0 } };
>
> int ret = 0;
> memset(&netcfg, 0 , sizeof(struct virtio_net_config));
> @@ -151,7 +152,11 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
> ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
> n->config_size);
> if (ret != -1) {
> - memcpy(config, &netcfg, n->config_size);
> + if (memcmp(&netcfg.mac, &zero, sizeof(zero)) != 0) {
> + memcpy(config, &netcfg, n->config_size);
> + } else {
> + error_report("Get an all zero mac address from hardware");
This is probably a hint that MAC is not properly provisioned.
So I guess we can leave this as is, or simply warn until the management
interface is finalized.
> + }
> }
> }
> }
> @@ -3399,6 +3404,11 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
> nc = qemu_get_queue(n->nic);
> nc->rxfilter_notify_enabled = 1;
>
> + if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
> + struct virtio_net_config netcfg = {};
> + memcpy(&netcfg.mac, &n->nic_conf.macaddr, ETH_ALEN);
> + virtio_net_set_config(vdev, (uint8_t *)&netcfg);
Won't this overwrite all other fields in the netcfg? I think we should
only touch mac part.
Thanks
> + }
> QTAILQ_INIT(&n->rsc_chains);
> n->qdev = dev;
>
next prev parent reply other threads:[~2020-09-22 1:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-17 15:58 [PATCH 1/3] virtio-net: Set mac address to hardware if the peer is vdpa Cindy Lu
2020-09-17 15:58 ` [PATCH 2/3] vhost-vdpa: Add qemu_close in vhost_vdpa_cleanup Cindy Lu
2020-09-22 1:56 ` Jason Wang
2020-09-17 15:58 ` [PATCH 3/3] net: Add vhost-vdpa in show_netdevs() Cindy Lu
2020-09-22 1:56 ` Jason Wang
2020-09-22 1:54 ` Jason Wang [this message]
2020-09-22 3:01 ` [PATCH 1/3] virtio-net: Set mac address to hardware if the peer is vdpa Cindy Lu
2020-09-24 7:18 ` Jason Wang
2020-09-25 7:46 ` Cindy Lu
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=b5ac3a30-6d81-117c-37af-e16b9a21ddad@redhat.com \
--to=jasowang@redhat.com \
--cc=lulu@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.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).