Skip to contentSkip to conversation

virtio-net: Set mac address to hardware if the peer is vdpa

PATCH Applied Cindy Lu 2 participants 2 messages Sep 25, 2020 – Oct 16, 2020

lore
Share & tools
lore

Cindy Lu

author
#0 lore raw

PATCH v2 1/1 virtio-net: Set mac address to hardware if the peer is vdpa

If the peer's type is vdpa, we need to set the mac address to hardware in virtio_net_device_realize,

---
 hw/net/virtio-net.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/net/virtio-net.c +6 -0
index cb0d27084c..1f2c1643bf 100644
@@ -3399,6 +3399,12 @@ 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);
+        vhost_net_set_config(get_vhost_net(nc->peer),
+            (uint8_t *)&netcfg, 0, ETH_ALEN, VHOST_SET_CONFIG_TYPE_MASTER);
+    }
     QTAILQ_INIT(&n->rsc_chains);
     n->qdev = dev;
 
Signature · 1 line
2.21.3
Applied
#1 lore raw
Quoted 15 lines · Cindy Lu

If the peer's type is vdpa, we need to set the mac address to hardware in virtio_net_device_realize,

---
  hw/net/virtio-net.c | 6 ++++++
  1 file changed, 6 insertions(+)
hw/net/virtio-net.c +0 -0
index cb0d27084c..1f2c1643bf 100644
@@ -3399,6 +3399,12 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
      nc = qemu_get_queue(n->nic);
      nc->rxfilter_notify_enabled = 1;

hw/net/virtio-net.c static void virtio_net_device_realize(DeviceState *dev, Error **errp) · line 3410

Quoted 10 lines
hw/net/virtio-net.c +6 -0
 
+   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);
+        vhost_net_set_config(get_vhost_net(nc->peer),
+            (uint8_t *)&netcfg, 0, ETH_ALEN, VHOST_SET_CONFIG_TYPE_MASTER);
+    }
      QTAILQ_INIT(&n->rsc_chains);
      n->qdev = dev;
 

Applied.

Thanks